Skip to content

Instantly share code, notes, and snippets.

@dogancankilment
Last active April 4, 2016 19:54
Show Gist options
  • Save dogancankilment/247363a17e0a462ddf74 to your computer and use it in GitHub Desktop.
Save dogancankilment/247363a17e0a462ddf74 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StandardDeviation
{
public static class Program
{
static void Main(string[] args)
{
Random rnd = new Random();
List<double> scores = new List<double>();
for (int i = 0; i < 95; i++)
{
scores.Add((double)rnd.Next(0, 100));
}
StandardDeviation(scores);
}
public static double StandardDeviation(this List<double> values)
{
double avg = values.Average();
return Math.Sqrt(values.Average(v => Math.Pow(v - avg, 2)));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment