Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Error in standard deviation calculation in MS for VB 2008

There is an error in the standard deviation calculation!!!!

 

Dim numArray() as Double = {19.14, 31.14, 28.14}

Dim

 

dStdev As Double = NationalInstruments.Analysis.Math.Statistics.StandardDeviation(numArray)

dStdev = 5.0990195135927845

 

Actual standard deviation: 6.244998

 

Version 8.9.20.246

0 Kudos
Message 1 of 6
(4,314 Views)

Hi Steverino,

 

I am not sure how you are calculating your standard deviation, but this might be where we are running into a difference.  The Measurement Studio help specifies that we calculate the population standard deviation. To calculate the sample standard deviation you should refer to the Measurement Studio help on the method and follow the instructions to do so.

 

Thanks

Ryan T
National Instruments
Applications Engineer
0 Kudos
Message 2 of 6
(4,298 Views)

Hi Steve,

 

I'm assuming your using Excel to calculate standard deviation

 

The STDEV formula gives 6.244 as an answer.

 

The STDEVP formula gives 5.09902 as an answer

 

STDEVP uses the following formula:

Formula

where x is the sample mean AVERAGE(number1,number2,…) and n is the sample size.

 

 

  • STDEV uses the following formula:

     

    Formula

    where x is the sample mean AVERAGE(number1,number2,…) and n is the sample size.

  •  

     

    Curt

     

     

    0 Kudos
    Message 3 of 6
    (4,296 Views)

    Also,

     

    Both formulas return the same value for larger population sizes.

    I could be wrong but I think you should to have a population of around 36 or higher to calculate any meaningful standard deviation data

     

    Curt 

    0 Kudos
    Message 4 of 6
    (4,293 Views)

    Thanks, for the information. I should have checked for the population standard deviation. Actually, I used my TI-36X calculator to calculate the standard deviation "s". 

     

    The one to use (sample vs population) actually has nothing to do with the number of data points. The determining factor is this: Are we dealing with the population or a subset (sample) of the population? In most cases we are dealing with subsets of the population, and therefore the sample standard deviation is the correct formula. As the sample size gets larger, the difference between the two gets smaller. After a sample size of thirty or so they are virtually the same.

     

    For example, if we wanted to measure the standard deviation in weight of every male in the US we could report the population standard deviation only if we actually measured the weight of every male in the US. Practically speaking we would be taking only a small subset of all males and therefore we are reporting the sample standard deviation.

     

    Ryan, in response to your comments, the NI documentation is poor on this topic. Aside from the syntax descriptions, the entire description of the function in the online help for the Analysis.Math namespace is this: "Computes the standard deviation of the values in the input array." No mention of sample vs population calculations.

     

    IMHO, the only thing NI does poorly is documentation.

     

    0 Kudos
    Message 5 of 6
    (4,279 Views)

    Hi Steverino,

     

    When searching the Measurement Studio help the Local Help will return the most usefull information.  If search for standarddeviation the first hit that returns is Statistics.StandardDeviation Method.  If we open the help on this topic it goes over a lot of information on the function.  If you take a look at the Remarks section this is where you will find the information that you are searching for.

     

    Thanks

    Ryan T
    National Instruments
    Applications Engineer
    0 Kudos
    Message 6 of 6
    (4,262 Views)