Welford’s method for computing variance

The standard deviation is a measure of how much a dataset differs from its mean; it tells us how dispersed the data are. A dataset that’s pretty much clumped around a single point would have a small standard deviation, while a dataset that’s all over the map would have a large standard deviation. Given a …

Grouping data

Suppose you are faced with the task of taking a list of things and grouping them by some attribute, like turning the following list country-city pairs… input=[(“USA”, “New York”), (“USA”, “San Francisco”), (“USA”, “Los Angeles”), (“UK”, “London”), (“UK”, “Manchester”), (“UK”, “Edinborough”), (“Spain”, “Madrid”), (“Spain”, “Barcelona”), (“Spain”, “Granada”), (“Finland”, “Helsinki”), (“Finland”, “Oulu”), (“Finland”, “Kuopio”)] into lists of …