standaard-deviatie-stdev

Gesponsorde koppelingen

PHP script bestanden

  1. standaard-deviatie-stdev

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?PHP

function standard_deviation ($a)
                {

                  //variable and initializations
                  $the_standard_deviation = 0.0;
                  $the_variance = 0.0;
                  $the_mean = 0.0;
                  $the_array_sum = array_sum($a); //sum the elements
                  $number_elements = count($a); //count the number of elements
                
                  //calculate the mean

                  $the_mean = $the_array_sum / $number_elements;
                
                  //calculate the variance
                  for ($i = 0; $i < $number_elements; $i++)
                  {

                    //sum the array
                    $the_variance = $the_variance + ($a[$i] - $the_mean) * ($a[$i] - $the_mean);
                  }

                
                  $the_variance = $the_variance / ($number_elements - 1.0);
                
                  //calculate the standard deviation
                  $the_standard_deviation = pow( $the_variance, 0.5);
                
                  //return the variance
                  return $the_standard_deviation;
                }



$a = array(2, 3, 5, 2, 10, 0, 10, 10, 0, 10, 0, 0);
$STDEV =  standard_deviation ($a);
echo $STDEV;  // uitkomst 4,438126823

?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.