-2

I was given 5 (double) values, I've declared the array and worked out the mean by using .Average; but need to work out the Standard deviation and have no clue!! I've looked through other answers but they confuse me i want to keep it as simple and possible, please help me!

corkonian
  • 1
  • 1
  • This is a programming website. If you need help with programming, you need to give the Standard Deviation formulas, so you can find help very quickly. Not everybody on this site remember everything about statistics and some other math stuffs. – Auguste Nov 08 '14 at 14:53
  • This question appears to be a mathematical one. Parhaps reading an artical on [Standard Deviation](http://en.wikipedia.org/wiki/Standard_deviation) might help? If you are looking for a way to implement the calculation of the Standard Deviation take a look at other posts: http://stackoverflow.com/questions/5336457/how-to-calculate-a-standard-deviation-array – MrPaulch Nov 08 '14 at 14:54

1 Answers1

1

Here you have it:

public static void Main(string[] args)
{
    double[] array = {1.2, 2.3, 3.4, 4.5, 8.9};
    double average = array.Average();
    double sd = Math.Sqrt(array.Sum(x => Math.Pow(x - average, 2) / array.Length));
    Console.WriteLine("Average: " + average);
    Console.WriteLine("Standard deviation: " + sd);
}

Here you can find the standard deviation formula.

Andrew
  • 7,602
  • 2
  • 34
  • 42