示例#1
0
        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));
        }
示例#2
0
        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)
            });
        }