Standard Deviation

Standard deviation is a measurement for the variations from the mean, for a set of values. You usually use small sigma as a sign for standard deviation.
I was asked to create a solution which got measurements from BAC (HP) within a certain amount of time.
They wanted to display these values, the mean and recommended values for the thresholds (red/yellow) in a graph. I then thought I could create this by calculating the standard deviation.
These values were supposed to be measured within a “normal stability period”.
They wanted to calculate the recommended thresholds in which to set in BAC.

This is the formula for the standard deviation:

black formula

I used curl and BAC OpenApi to get the values from BAC.
I created a generic query, which got all the Monitors and transactions from BAC.
This query then created a «Select form», where you could choose which transaction you wanted to analyze.

When you choose the transaction, there is a query to the OpenApi with Curl and you get the timestamp and response for a given amount of time.
I parse this data and puts the values in different array’s.

I then get the sum of all the values in the response array.
I then get the amount of measurements in the response array, by using count($array_response) in php.
I then get the mean from this array by using the formula:

black

I then have to take each values in the array_respons minus the mean and exp in 2.
I then needed to take the square root of the sum of these values.
This value is the standard deviation.

sample php code:
(median_svar is the mean of the array)

foreach ( $array_response as $value ) {
$median_row=($value/1000)-$median_svar;
$expo+=($median_row*$median_row);
}
$median_endvalue=sqrt($expo/$antall_svar);

The standard deviation is $median_end_value.

Using Chebyshev’s inequality, I calculated the recommended thresholds for yellow and red in BAC.
I also took some considerations in the calculation of these thresholds by checking the
relation between the mean and the standard deviation.

Chebyshev’s inequality:

At least 50% of the values are within ?2 standard deviations from the mean.

At least 75% of the values are within 2 standard deviations from the mean.

At least 89% of the values are within 3 standard deviations from the mean.

At least 94% of the values are within 4 standard deviations from the mean.

At least 96% of the values are within 5 standard deviations from the mean.

At least 97% of the values are within 6 standard deviations from the mean.

At least 98% of the values are within 7 standard deviations from the mean.

Legg igjen en kommentar

Din e-postadresse vil ikke bli publisert. Obligatoriske felt er merket med *