0

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 neg2StdDevFromMean = mean - (2 * stdDev);
double negOneStdDevFromMean = mean - (1 * stdDev);
double negOneHalfStdDevFromMean = mean - (0.5 * stdDev);

Thanks!

O.O
  • 11,077
  • 18
  • 94
  • 182

1 Answers1

1

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.

Community
  • 1
  • 1
Ani
  • 111,048
  • 26
  • 262
  • 307