1 comment:

  1. php
    $n=$_POST['num'];
    $str=$_POST['arr'];
    $x=explode(',',$str);
    $sum=0;
    $sum1=0;
    for($i=0;$i<$n;$i++)
    {$sum=$sum+$x[$i];
    }
    $mean=$sum/$n;
    echo"$sum
    ";
    echo"$mean
    ";
    for($i=0;$i<$n;$i++)
    {$t[$i]=($x[$i]-$mean); // subtracting mean from individual value and squaring the result(after subtracting) in next step
    $square[$i]=(pow($t[$i],2));
    }
    print_r($t);
    print_r($square);
    for($i=0;$i<$n;$i++)
    {$sum1=$sum1+$square[$i]; // calculating sum of square
    }
    $avg=$sum1/$n; // finding mean of above calculated sum
    $standard_Deviation=sqrt($avg);
    echo"
    standard deviation is=$standard_Deviation";
    ?>

    ReplyDelete