Data Science Data Distribution
A data distribution describes how values in a dataset are spread across their range, and it's the first thing worth checking before you plot, model, or summarize anything.
What Is a Data Distribution?
A distribution is simply a description of how often each value, or range of values, shows up in a dataset. Two datasets can share the same mean and still look completely different once you see how their values are spread out.
Example
import numpy as np
# 250 random integers, each between 0 (inclusive) and 100 (exclusive)
data = np.random.randint(0, 100, 250)
print(data[:10])
print("mean:", np.mean(data))
print("std dev:", np.std(data))Printing the raw numbers doesn't tell you much on its own - with 250 values, no one can eyeball a pattern. Grouping the values into a chart is what turns a list of numbers into a shape you can reason about.
Visualizing With a Histogram
Example
import matplotlib.pyplot as plt
plt.hist(data, bins=10)
plt.xlabel("Value")
plt.ylabel("Count")
plt.show()A histogram sorts values into equal-width bins and draws a bar for how many values fall in each one. Tall bars mark where values cluster; short or empty bars mark ranges the data rarely visits.
- Where the peak (or peaks) of the bars sit
- How wide or narrow the spread of bars is
- Whether one side trails off more slowly than the other (skew)
- Any bars sitting far away from the rest (possible outliers)
Distribution Shapes You'll See
Random integers like the ones above tend to spread out fairly evenly across their range - that's called a uniform distribution. Many real-world measurements instead cluster tightly around a center and taper off symmetrically at both ends, which is the normal distribution covered next.
Exercise: Data Science Data Distribution
What does a data distribution describe?