Last updated

Data Distribution

Definition: A data distribution describes how values are spread across a range. ML models often assume data follows a certain shape, so it helps to generate and inspect data.

Example — create a random dataset

NumPy can generate realistic data. Here we make 250 "heights" centred on 170cm with a spread of 10cm:

import numpy as np
heights = np.random.normal(170, 10, 250)
print("Count:", len(heights))
print("Mean: ", round(heights.mean(), 1))
print("Min:  ", round(heights.min(), 1))
print("Max:  ", round(heights.max(), 1))

Run it a few times — because the data is random, the numbers shift slightly each time, but the mean stays close to 170.

The normal distribution

The "normal" (bell-curve) distribution appears everywhere in nature — heights, test scores, measurement errors. Most values sit near the middle, with fewer at the extremes.

💡 Tip: np.random.normal(mean, spread, count) is a quick way to make sample data for experiments.

Try it Yourself
Output

          
Ad · responsive