Public
Edited
Nov 27, 2023
Insert cell
Insert cell
viewof step = Inputs.range([0,500000],{step:1})
Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
Plot.plot({
x:{domain:[0,10]},
y:{domain:[0,20]},
marks:[
Plot.ruleX([0]),
Plot.ruleY([0]),
Plot.dot(X,{x:X,y:Y,r:5,fill:'black'}),
Plot.line(x,{x:x,y:y,stroke:'red'}),
Plot.dot(X2,{x:X2,y:Y2,r:5,fill:'blue'}),
]
})
Insert cell
f = x => a*x**2+b*x+c
Insert cell
x = {
const x = []
for(let i = 0; i <= 10; i = i + .1){
x.push(i)
}
return x
}
Insert cell
y = x.map(x => f(x))
Insert cell
X = [3,7,9]
Insert cell
Y = X.map((X,i) => 2*X+1 + error[i])
Insert cell
error = X.map(X => d3.randomNormal(0,3)())
Insert cell
loss = (9*a+3*b + c -3.8630544814190437)**2 + (49*a+7*b+c -14.496780640129042)**2 + (81*a+9*b+c-14.538659411550247)**2
Insert cell
lossPrimea = (a,b) => 196*a+28*b-46
Insert cell
lossPrimeb = (a,b) =>28*a+6*b-18
Insert cell
lossPrimec = (a,b,c) =>278*a + 38*b + 6.000000000000000*c - 65.79698906619667
Insert cell
X2 = [1,6,10]
Insert cell
error2 = X.map(X => d3.randomNormal(0,3)())
Insert cell
Y2 = X.map((X,i) => 2*X+1 + error[i])
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.
Learn more