Skip to main content
Albero Academy

Statistics

Describe data with means, percentiles, correlation and histograms.

Numerical Computing9 min

NumPy has enough statistics built in to describe a dataset without any extra library — the summary numbers you compute constantly plus histograms, which turn raw values into a distribution.

Central tendency & spread

summary numbers
data = rng.normal(60, 15, 1000)
data.mean() # average
np.median(data) # middle value (robust to outliers)
data.std() # standard deviation
np.percentile(data, [25, 75]) # the quartiles

Correlation & histograms

relationships & distributions
np.corrcoef(hours, scores) # correlation matrix (−1 to +1)
counts, edges = np.histogram(data, bins=10) # distribution shape

Key takeaways

  1. 01mean/median/std/percentile summarise centre and spread.
  2. 02Median and IQR are robust to outliers; prefer them for skewed data.
  3. 03np.corrcoef measures how strongly two variables move together (−1 to +1).
  4. 04np.histogram counts values per bin to reveal a distribution's shape.

Finished this chapter?

Mark it complete to track your progress through NumPy.