Actually, you should compute $number, $sum, and $sqsum (which is the sum of the squares of all of the numbers) as you go and then you can compute standard deviation without having to loop a second time.
I'll omit the details of the calculation since you can probably just look them up in Statistics::Descriptive, though I find deriving the formula is a good way to see if you remember any of your math classes. (:
This standard trick allows you to add numbers to the set (or even remove some) and recalculate the average and stddev without having to even keep the list of numbers around, much less loop through them.
- tye (but my friends call me "Tye")In reply to (tye)Re: Still confused
by tye
in thread Still confused
by yabba
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |