开发者

Calculate number of standard deviations from the mean

Here's what I have:

  1. Standard Deviation
  2. Mean
  3. 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:

  1. For -2, -1, -0.5, 0, 0.5, 1, 2 standard deviations from the mean calculate the count of where each fall
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜