Calculate number of standard deviations from the mean
Here's what I have:
- Standard Deviation
- Mean
See code
double[] series = { 150, 233, 80, 300, 200, 122, 125, 199, 255, 267, 102, 299 }; double stdDev = CalculateStdDev(series); double mean = series.Average();
I need help to create a method to produce the following below:
- For -2, -1, -0.5, 0, 0.5, 1, 2 standard deviations from the mean calculate the count of where each fall
- The result from number one should be in coordinate pairs like so: (-2, n), (-1, n), (0, n), (1, n), (2, n).
The purpose is to produce a normal curve or bell curve.
Example:
double mean = 194;
double neg2开发者_运维技巧StdDevFromMean = mean - (2 * stdDev);
double negOneStdDevFromMean = mean - (1 * stdDev);
double negOneHalfStdDevFromMean = mean - (0.5 * stdDev);
Thanks!
The question isn't all that clear, but maybe you want something like:
var query = from numStdDev in new[] { -2, -1, -0.5, 0, 0.5, 1, 2 }
select new
{
NumStdDev = numStdDev,
Value = mean + numStdDev * stdDev
};
If by "co-ordinate pair", you're referring to System.Drawing.PointF
, you can do:
var query = from numStdDev in new[] { -2, -1, -0.5, 0, 0.5, 1, 2 }
select new PointF
((float)numStdDev, (float)(mean + numStdDev * stdDev));
If you want help with calculating the standard deviation itself, you might want to look at: LINQ Equivalent for Standard Deviation.
精彩评论