Linear Regression

Use JScript to generate data points. Enter the coefficients for the best fit.  Start

y=mx+b

m=  b=


Script Example

<script language="JavaScript">
function plotRegression(){
    document.DataGraph.setAutoRefresh(false);
    document.DataGraph.deleteAllFunctions();
    rid=document.DataGraph.plotRegression(1);
    document.DataGraph.setRGB(rid,255,0,0);
    fstr=document.DataGraph.getFunctionString(rid);
    document.DataGraph.setTitle(fstr);
    document.DataGraph.setAutoscaleY(false);
    document.DataGraph.setAutoscaleY(true);
    document.DataGraph.setAutoRefresh(true);
}
function plotData(){
    document.DataGraph.setAutoRefresh(false);
    document.DataGraph.setTitle("Regression Analysis");
    document.DataGraph.deleteAllFunctions();
    document.DataGraph.clearSeries(1);
    document.DataGraph.setSeriesStyle(1,false,2);
    document.DataGraph.setSeriesRGB(1,255,0,0);
    x=0; dx=1.0/20.0; pi=Math.PI;
    for(i=0; i<20;i++){
        document.DataGraph.addDatum(1,x,2*x-4+Math.random()*0.2);
        x+=dx;
    }
    document.DataGraph.setAutoRefresh(true);
}
</script>