standard deviation

by Anjali Jain

JavaScript

<!DOCTYPE HTML>
<html>
<head>
  <script type="text/javascript">
  window.onload = function () {
        var dataPoints = [];
        var total = 0, total1 = 0, mean;
        var y = [2,5,3,4,6,7,8];
        for(var i = 0; i <= y.length-1; i++) {
            total += y[i]; 
        }  
        mean  = total / y.length;
        for(var i = 0; i <= y.length-1; i++){
            total1 += Math.pow((y[i]-mean),2);
        }
        standardDeviation = total1/y.length;
        console.log(standardDeviation);

        var chart = new CanvasJS.Chart("chartContainer", {
        title: {
          text: "Graph with standard deviation",
        },
        data: [
        {
            showInLegend: true,
            type: "line",
            dataPoints: dataPoints,
        }
        ]
    });

    chart.render();
  }
  </script>
 <script type="text/javascript" src="CanvasJS.js"></script></head>
<body>
  <div id="chartContainer" style="height: 300px; width: 100%;">
  </div>
</body>
</html>