Results 1 to 5 of 5

Math Help - Standard Deviation

  1. #1
    Newbie
    Joined
    Dec 2005
    Posts
    2

    Standard Deviation

    HI All,

    I am trying to calculate the standard deviation of a given set of numbers.

    E.g. 1,2,3,4,5

    If i use excel and the STDEV function i get 1.58113883
    which is all good. But if i go to http://invsee.asu.edu/srinivas/stdev.html and enter the same numbers I get 1.4142135623730951

    Now the the problem i have is in a vb.net program I have written a function that returns the latter of the two numbers. Which i believe is wrong.

    1. Which number is correct?

    2. If anyone knows vb.net is the below code correct? This returns the second value of the two.

    Public Function standard deviation(ByVal Inputdata() As Double) As Double

    Dim DataAverage As Double = 0
    Dim TotalVariance As Double = 0


    DataAverage = SMA(Inputdata)'get our moving average value

    For i = 0 To Inputdata.Length - 1
    TotalVariance = (TotalVariance + Math.Pow((Inputdata(i) - DataAverage), 2))
    Next

    StandardDeviation = Math.Sqrt(TotalVariance / Inputdata.Length))

    End Function

    Any ideas? Or pointers.

    Thanks
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    The problem is that there are two entities out there calling themselves
    "standard deviation"

    s_N=\sqrt{\frac{1}{N} \sum_{i=1}^N(x_i-\bar x)^2}

    which is the square root of the sample variance if \{x_1,\ ..\ x_N \} is
    a sample of size N from some population. Or the square root of
    the variance of a random variable which takes the values
    x_1,\ ..\ x_N with equal probability.

    s_{N-1}=\sqrt{\frac{1}{N-1} \sum_{i=1}^N(x_i-\bar x)^2}

    which is the square root of the bias corrected estimate of the
    population variance that \{x_1,\ ..\ x_N \} is a sample of size N from.

    Now which you use is up to you and could depend on what you wish to
    do with it. But apparently s_{N-1} is now commonly used in software
    packages as the definition of standard deviation - with poor justification.

    However for large samples these are very close and so the difference does
    not matter, but if I were you I would stick to s_N.

    RonL
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Global Moderator

    Joined
    Nov 2005
    From
    New York City
    Posts
    10,616
    Thanks
    10
    I just have a curious question. I never studied Probabilty nor Statistics in full detail but I happen to know what Strandard Deviation is. The question I have is why not use the Mean-Absolute Deviation instead? Is it because Standard Deviation is useful in Probability and Statistics? And if yes, where?
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by ThePerfectHacker
    I just have a curious question. I never studied Probabilty nor Statistics in full detail but I happen to know what Strandard Deviation is. The question I have is why not use the Mean-Absolute Deviation instead? Is it because Standard Deviation is useful in Probability and Statistics? And if yes, where?
    A number of reasons, mainly related to analytic tractability.

    One could possibly be because of the asymptotic relationship between
    maximum likelihood estimators, and minimum variance estimators.

    The ubiquity of the Normal Distribution, and variance being one of
    its natural parameters.

    Distributions are charaterised by their moments, and variance is
    the 2-nd central moment.

    Also the Mean Deviation is used - but not so frequently.

    RonL
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Dec 2005
    Posts
    2
    Thanks guys. Gives me a better idea of what is going on.

    FYI I am using the calculation for looking at price action on a currency chart and deterring when it has moved too far from its average. Then taking trades with the anticipation of it reverting back to its mean/average.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Standard Deviation
    Posted in the Statistics Forum
    Replies: 4
    Last Post: September 8th 2010, 04:05 AM
  2. Replies: 5
    Last Post: May 18th 2009, 05:14 AM
  3. standard deviation and mean deviation
    Posted in the Statistics Forum
    Replies: 1
    Last Post: March 16th 2008, 06:09 AM
  4. i need standard deviation help
    Posted in the Statistics Forum
    Replies: 2
    Last Post: February 22nd 2008, 06:03 PM
  5. The mean and standard deviation
    Posted in the Advanced Statistics Forum
    Replies: 3
    Last Post: February 17th 2008, 09:15 PM

Search Tags


/mathhelpforum @mathhelpforum