Re: VHDL code for finding standard deviation for a chunk of numbers



"Pratap" <pratap.iisc@xxxxxxxxx> wrote in message
news:1bc417fc-61e2-44d9-a1d4-969ae79a9661@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Yes...variance will also do...

Well, depending on your need for speed, I can assume you can take your time
and build up the necessary sums. The variance is the mean square minus the
mean squared (subtle addition of the d means something here). So, your
algorithm looks like this:

1. Define two numbers: sum, sumsq
2. Set both to zero to start
3. For each point from 1 to N:
sum <= sum + x;
sumsq <= sumsq + (x * x);

When done:
mean <= sum / N; -- Here's the mean if you need it
var <= sumsq / N - (mean * mean);

Power of two divisions can of course be replaced by shifts, or if you want
some form of floating point you are adjusting the exponent and leaving the
mantissa alone. If you want the variance of a number stream relative to a
forced zero mean you can dispense with the calculation of the mean and just
take the sum of squares divided by N.

-Marty


.



Relevant Pages

  • Re: z test how
    ... variance 2 is variance squared ... sum of V2/n = 0.0000145545 ... at the probability that is my probability that this 2 groups are ... It doesn't mean you need to square it. ...
    (sci.stat.edu)
  • Re: Biased and unbiased std dev
    ... unbiased estimate of by dividing by; taking the square root biases ... The reason for the bias is that when you take the average sum of squares ... subtracting out the variance of the sample mean itself (which will be ... deviations around it than any other value. ...
    (sci.stat.math)
  • Re: z test how
    ... Bruce Weaver wrote: ... variance 2 is variance squared ... sum of V2/n = 0.0000145545 ... It doesn't mean you need to square it. ...
    (sci.stat.edu)
  • Re: Standard Deviation
    ... Suppose you have five observations and want to compute the sum of the squared deviations from the mean. ... Now the square of 10015 is 100300225, which is divided by 5 to yield 20060045, and the SS is 20060055 minus 20060045, which is 10 as before. ... Using the computational formula is dangerous on computers when the mean is large and the variance is small relative to the mean ...
    (borland.public.delphi.non-technical)
  • every number has its own significance.....
    ... 18 is the only number that is twice the sum of its digits. ... 21 is the smallest number of distinct squares needed to tile a square. ... 26 is the only number to be directly between a square and a cube. ... 27 is the largest number that is the sum of the digits of its cube. ...
    (sci.crypt)