Skip to content
Saed Sayad

Numerical Variables

Summarize numerical variables with mean, median, mode, variance, standard deviation, IQR, skewness, and kurtosis, plus histograms and box plots.

5 min read · Updated August 8, 2026

A numerical (or continuous) variable is one that may take on any value within a finite or infinite interval — height, weight, temperature, blood glucose, and so on. Where categorical variables are summarized by counting, numerical variables are summarized by measuring: where is the center, how wide is the spread, and what shape does the distribution take?

Interval and Ratio Variables

There are two types of numerical variable. An interval variable has values whose differences are interpretable, but it has no true zero — temperature in degrees Centigrade is the classic case. Interval data can be added and subtracted but not meaningfully multiplied or divided: you cannot say that one day is twice as hot as another. A ratio variable has a true zero and supports all four arithmetic operations — weight is a good example, and 20 kg really is twice 10 kg.

Central Tendency

The mean is the sum of the values divided by the count:

xˉ=1ni=1nxi\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i

The median is the middle value of the sorted data — below and above it lies an equal number of values. For sorted values x(1)x(n)x_{(1)} \le \dots \le x_{(n)}:

x~={x(n+12)n odd12(x(n2)+x(n2+1))n even\tilde{x} = \begin{cases} x_{\left(\frac{n+1}{2}\right)} & n \text{ odd} \\ \frac{1}{2}\left(x_{\left(\frac{n}{2}\right)} + x_{\left(\frac{n}{2}+1\right)}\right) & n \text{ even} \end{cases}

The mode is the most frequent value; there can be more than one. The median is robust to outliers while the mean is not — when they disagree, the distribution is skewed or contaminated, and the gap is itself a finding.

Dispersion

The range is maxmin\max - \min. The variance measures average squared distance from the mean:

s2=i=1n(xixˉ)2n1s^2 = \frac{\sum_{i=1}^{n} (x_i - \bar{x})^2}{n - 1}

and the standard deviation is its square root, s=s2s = \sqrt{s^2}, which returns the measure to the original units. The coefficient of variation expresses dispersion relative to the mean, making spread comparable across variables of different scales:

cv=sxˉcv = \frac{s}{\bar{x}}

Quantiles are cut points dividing the sorted data into groups of equal size — quartiles (4 groups), quintiles (5), percentiles (100). The interquartile range, IQR=Q3Q1\mathrm{IQR} = Q_3 - Q_1, spans the middle 50% of the data and is the dispersion measure behind the box plot.

Shape

Skewness measures asymmetry of the distribution — positive skew means a long right tail, negative skew a long left tail:

g1=n(n1)(n2)i=1n(xixˉs)3g_1 = \frac{n}{(n-1)(n-2)} \sum_{i=1}^{n} \left( \frac{x_i - \bar{x}}{s} \right)^3

Kurtosis measures whether the data are peaked or flat relative to a normal distribution (a normal distribution has excess kurtosis of 0):

g2=n(n+1)(n1)(n2)(n3)i=1n(xixˉs)43(n1)2(n2)(n3)g_2 = \frac{n(n+1)}{(n-1)(n-2)(n-3)} \sum_{i=1}^{n} \left( \frac{x_i - \bar{x}}{s} \right)^4 - \frac{3(n-1)^2}{(n-2)(n-3)}

Visualization

The histogram bins the values and plots a bar per bin — it reveals modality, skew, and outliers at a glance. The box plot compresses the distribution into five numbers: the box spans Q1Q_1 to Q3Q_3 with a line at the median, whiskers extend toward the extremes (typically 1.5×IQR1.5 \times \mathrm{IQR}), and points beyond are drawn individually as outlier candidates.

Box plot of sepal length for the Iris dataset: the box runs from the first quartile 5.1 to the third quartile 6.4 with the median at 5.8, and whiskers extending to 4.3 and 7.9.
Box plot of sepal length (Iris dataset).
Histogram of sepal length for the Iris dataset: a roughly bell-shaped distribution centered near 5.8 with a slight right skew.
Histogram of sepal length (Iris dataset).

Worked Example: Iris Sepal Length

The legacy example analyzes the sepal length variable from the Iris dataset (n=150n = 150):

StatisticValue
Count150
Minimum4.3
Maximum7.9
Mean5.84
Median5.8
Mode5.0
Quartile 15.1
Range3.6
Variance0.69
Standard Deviation0.83
Coefficient of Variation14.2%
Skewness0.31
Kurtosis−0.55

Read together: the mean (5.84) sits just above the median (5.8), consistent with the mild positive skewness (0.31); the CV of 14.2% says the spread is modest relative to the center; and the negative excess kurtosis (−0.55) indicates slightly flatter tails than a normal curve.

In Practice

df.describe() in pandas returns count, mean, std, min, quartiles, and max in one call; scipy.stats.skew and scipy.stats.kurtosis add shape. These summaries feed directly into modeling decisions: heavy skew motivates log transforms before linear regression, outliers visible in a box plot motivate robust scalers, and standardization (subtracting xˉ\bar{x}, dividing by ss) is the default preprocessing for SVMs, k-NN, and neural networks.

Common Pitfalls

  • Reporting the mean of a skewed variable without the median — one outlier can pull the mean far from the typical value.
  • Comparing standard deviations across variables with different scales; use the coefficient of variation instead.
  • Trusting statistics without the plot. Anscombe-style pathologies hide from summary numbers; always look at the histogram.
  • Mixing up population and sample variance (nn vs. n1n-1 in the denominator) when comparing tools — Excel’s VAR.P/VAR.S differ for exactly this reason.
  • Reading kurtosis as “peakedness” alone — it is dominated by tail weight, and only meaningful on a decent sample size.

Summary

Numerical variables are interval or ratio, and their univariate profile has three layers: central tendency (mean, median, mode), dispersion (range, variance, standard deviation, IQR), and shape (skewness, kurtosis). The histogram and box plot make all three visible, and the Iris example shows how the numbers and pictures corroborate each other.