Data Science Normal Data Distribution

The normal distribution is a symmetric, bell-shaped pattern that many real-world measurements follow, and numpy.random.normal generates realistic samples of it in one line.

The Bell Curve

A normal distribution is symmetric around its mean: values close to the average are common, and values get rarer the farther they sit from it in either direction. Plotted as a histogram, it forms the familiar bell shape - tall in the middle, thin at both tails.

Generating Normal Data with NumPy

numpy.random.normal(loc, scale, size) draws size samples from a normal distribution centered at loc (the mean), with scale controlling the standard deviation - how tightly the values cluster around that center.

Example

import numpy as np
import matplotlib.pyplot as plt

# 100,000 samples: mean (loc) = 170, standard deviation (scale) = 10
heights = np.random.normal(170, 10, 100000)

plt.hist(heights, bins=100)
plt.xlabel("Height (cm)")
plt.ylabel("Count")
plt.show()

Run this and the histogram comes out symmetric and bell-shaped, peaking around 170 with the bars thinning out evenly toward both 140 and 200. Change scale to 20 and the same bell gets visibly wider and flatter, without moving its center.

Real-World Quantities That Follow It

  • Adult height within a population
  • Small measurement errors from a precise instrument
  • Standardized test scores across a large group of test-takers
  • Reaction times averaged across many trials

The 68-95-99.7 Rule

RangeApprox. share of the data
mean +/- 1 standard deviation68%
mean +/- 2 standard deviations95%
mean +/- 3 standard deviations99.7%

Example

import numpy as np

mean, std = 170, 10
heights = np.random.normal(mean, std, 100000)

within_1_std = (heights > mean - std) & (heights < mean + std)
print("share within 1 std dev:", np.mean(within_1_std))    # close to 0.68

within_2_std = (heights > mean - 2 * std) & (heights < mean + 2 * std)
print("share within 2 std dev:", np.mean(within_2_std))    # close to 0.95
Note: np.mean() on a boolean array is a quick trick worth remembering: True counts as 1 and False as 0, so the mean of a condition is exactly the fraction of values that satisfy it.