Platform
Resources
Pricing
Sign in
Get started
Mika Uthmann
Workspace
Fork
Public
By
Mika Uthmann
Edited
Jun 23, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
bits
=
{
const
allBits
=
initialBits
.
slice
(
)
;
const
newBits
=
[
]
;
for
(
let
i
=
initialBits
.
length
-
1
;
i
<
numberOfPoints
;
i
++
)
{
allBits
.
push
(
nextBit
(
i
,
allBits
)
)
;
newBits
.
push
(
nextBit
(
i
,
allBits
)
)
;
}
return
allBits
}
Insert cell
nextBit
=
(
k
,
bits
)
=>
{
return
bits
[
k
-
p
]
^
bits
[
k
-
p
+
q
]
}
Insert cell
Insert cell
Insert cell
naturalNumbers
=
{
const
naturalNumbers
=
[
]
;
for
(
let
i
=
initialBits
.
length
-
1
;
i
<
bits
.
length
;
i
++
)
{
let
naturalNumber
=
0
;
for
(
let
j
=
0
;
j
<
10
;
j
++
)
{
naturalNumber
+=
bits
[
i
-
j
]
*
2
**
j
}
naturalNumbers
.
push
(
naturalNumber
)
}
return
naturalNumbers
}
Insert cell
Insert cell
rationalNumbers
=
naturalNumbers
.
map
(
(
num
)
=>
num
/
2
**
10
)
Insert cell
rationalRange
=
[
d3
.
min
(
rationalNumbers
)
,
d3
.
max
(
rationalNumbers
)
]
Insert cell
Insert cell
findPeriod
(
bits
)
.
split
(
","
)
.
length
Insert cell
Insert cell
randomBits
=
{
const
rnd
=
new
mt
.
default
(
parseInt
(
1010101010
,
2
)
)
;
const
generated
=
[
]
;
for
(
let
i
=
0
;
i
<
numberOfPoints
-
9
;
i
++
)
generated
.
push
(
rnd
.
random
(
)
%
360
)
;
return
generated
;
}
Insert cell
Insert cell
// generating points for plot
plotPoints
=
{
const
points
=
[
]
;
for
(
let
i
=
0
;
i
<
parseInt
(
rationalNumbers
.
length
/
2
)
;
i
++
)
{
points
.
push
(
[
rationalNumbers
[
i
]
,
rationalNumbers
[
rationalNumbers
.
length
-
1
-
i
]
]
)
}
return
points
}
Insert cell
Insert cell
Insert cell
q
=
3
Insert cell
p
=
9
Insert cell
initialBits
=
[
1
,
0
,
1
,
0
,
1
,
0
,
1
,
0
,
1
,
0
]
Insert cell
randomPoints
=
{
const
points
=
[
]
;
for
(
let
i
=
0
;
i
<
parseInt
(
randomBits
.
length
/
2
)
;
i
++
)
{
points
.
push
(
[
randomBits
[
i
]
,
randomBits
[
randomBits
.
length
-
1
-
i
]
]
)
}
return
points
}
Insert cell
mt
=
await
import
(
"https://esm.sh/mersennetwister@0.2.3"
)
Insert cell
numPointsPlot
=
randomPoints
.
length
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
numberOfPoints
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
bits
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
nextBit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
generateBits
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
naturalNumbers
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
rationalNumbers
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
rationalRange
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
randomBits
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
plotPoints
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
findPeriod
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
calculateZArray
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
q
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
p
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
initialBits
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
randomPoints
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
mt
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
numPointsPlot
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML