Math-script demo
View Source
View Github
var X = M.range(-2.5,0.02,2.5); // Create input var Y = 4*X - X**3 + 2; // Main equation Y = Y.addNoise(0.5); Plots.create([X,Y],{type:'scatter',div:'myPlotData'}); var J = M.catH(X**3,X**2,X**1,X**0); // Jacobian var theta = M.pinv(J.t()*J)*J.t()*Y; // Normal equation var yH = J*theta; // Estimate Plots.add([X,yH],{type:'line',div:'myPlotData'});
Calculate