Last active
April 4, 2016 19:54
-
-
Save dogancankilment/247363a17e0a462ddf74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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