Exemple #1
0
        public double GetHighestStandardDeviation()
        {
            var personsByCities      = GetPersonsGroupedByCity();
            var maxStandardDeviation = 0.0d;

            foreach (var personsByCity in personsByCities)
            {
                var ages = ConvertPersonsToAges(personsByCity.Value);
                var standardDeviation = StandardDeviation.CalculateStandardDeviation(ages);

                if (standardDeviation > maxStandardDeviation)
                {
                    maxStandardDeviation = standardDeviation;
                }
            }

            return(maxStandardDeviation);
        }
Exemple #2
0
        public string GetCityWithLowestStandardDeviation()
        {
            var personsByCities      = GetPersonsGroupedByCity();
            var city                 = "";
            var minStandardDeviation = double.MaxValue;

            foreach (var personsByCity in personsByCities)
            {
                var ages = ConvertPersonsToAges(personsByCity.Value);
                var standardDeviation = StandardDeviation.CalculateStandardDeviation(ages);

                if (standardDeviation < minStandardDeviation)
                {
                    minStandardDeviation = standardDeviation;
                    city = personsByCity.Key;
                }
            }

            return(city);
        }