Platform
Resources
Pricing
Sign in
Get started
Herb Susmann
Workspace
Fork
Public
By
Herb Susmann
Edited
Apr 18, 2023
1 fork
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
random_noise
=
Array
(
N
)
.
fill
(
0
)
.
map
(
(
)
=>
rnorm
(
0
,
1
)
)
Insert cell
training_randomness
=
Array
(
N
)
.
fill
(
0
)
.
map
(
(
)
=>
Math
.
random
(
)
)
Insert cell
random_x
=
Array
(
N
)
.
fill
(
0
)
.
map
(
(
)
=>
rnorm
(
0
,
1
)
)
Insert cell
alpha
=
0.8
Insert cell
R_alpha
=
{
const
M
=
setup
.
data
.
filter
(
(
d
)
=>
d
.
training
==
false
)
.
length
;
const
R
=
setup
.
data
.
filter
(
(
d
)
=>
d
.
training
==
false
)
.
map
(
(
d
)
=>
d
.
R
)
.
sort
(
)
;
const
k
=
Math
.
ceil
(
(
alpha
)
*
(
M
-
1
)
)
;
return
R
[
k
]
;
}
Insert cell
intervals
=
{
const
N_pred
=
1e2
;
const
xmin
=
-
3
;
const
xmax
=
3
;
const
xs
=
Array
(
N_pred
)
.
fill
(
0
)
.
map
(
(
_
,
index
)
=>
xmin
+
(
xmax
-
xmin
)
/
(
N_pred
-
1
)
*
index
)
;
return
xs
.
map
(
(
x
)
=>
(
{
x
:
x
,
lower
:
setup
.
fit
.
predict
(
x
)
[
1
]
-
R_alpha
,
upper
:
setup
.
fit
.
predict
(
x
)
[
1
]
+
R_alpha
}
)
)
;
}
Insert cell
// slightly modified, from https://stackoverflow.com/questions/25582882/javascript-math-random-normal-distribution-gaussian-bell-curve
function
rnorm
(
mean
,
sd
)
{
let
u
=
0
,
v
=
0
;
while
(
u
===
0
)
u
=
Math
.
random
(
)
;
//Converting [0,1) to (0,1)
while
(
v
===
0
)
v
=
Math
.
random
(
)
;
return
(
Math
.
sqrt
(
-
2.0
*
Math
.
log
(
u
)
)
*
Math
.
cos
(
2.0
*
Math
.
PI
*
v
)
*
sd
)
+
mean
;
}
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
regression
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sigma
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
training
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
N
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
setup
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
random_noise
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
training_randomness
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
random_x
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
alpha
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
R_alpha
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
intervals
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
rnorm
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML