public double Calculate(IList <double> numbers) { var arithmeticMean = arithmeticMeanAlgorithm.Calculate(numbers); var differenceSquared = numbers.Select(n => Math.Pow(n - arithmeticMean, 2)); var squaredMean = arithmeticMeanAlgorithm.Calculate(differenceSquared.ToList()); return(Math.Sqrt(squaredMean)); }
public IndexViewModel Build() { var randomNumbers = randomNumberRepository.GetAll().Select(rn => rn.Number).ToList(); return(new IndexViewModel() { FrequencyDistribution = frequencyDistribution.Calculate(randomNumbers), Mean = arithmeticMean.Calculate(randomNumbers), StandardDeviation = standardDeviation.Calculate(randomNumbers) }); }