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); }
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); }