Descriptive statistics#

The term descriptive statistics refers to methods that allow summarizing collections of data. To demonstrate the most important methods, we start by defining a dataset first.

measurements = [5, 2, 6, 4, 8, 6, 2, 5, 1, 3, 3, 6]


Measurements of central tendency#

We can measure the location of our measurement in space using numpy’s statistics functions and Python’s statistics module.

import numpy as np
import statistics as st

np.mean(measurements)

4.25

np.median(measurements)

4.5

st.mode(measurements)

6


Numpy also allows measuring the spread of measurements.

np.std(measurements)

2.0052015692526606

np.var(measurements)

4.020833333333333

np.min(measurements), np.max(measurements)

(1, 8)

np.percentile(measurements, [25, 50, 75])

array([2.75, 4.5 , 6.  ])


Exercise#

Find out if the median of a sample dataset is always a number within the sample. Use these three examples to elaborate on this:

example1 = [3, 4, 5]

example2 = [3, 4, 4, 5]

example3 = [3, 4, 5, 6]