Math & Scientific
Find Variance in Data and Probability Distributions
Distinguish descriptive data variance from a random variable’s variance, derive E(X²)−E(X)², and check scaling and sample conventions.
Identify whether the inputs are data or probabilities
The word variance occurs in both descriptive statistics and probability. A raw list treats each listed observation with equal weight, including duplicates. A discrete random variable instead comes with outcomes and their probabilities, which need not be equal. The same squared-distance idea underlies both cases, but the weighting must match the object being described. Writing the intended mean and weights first prevents a probability problem from being accidentally turned into an unweighted data-summary exercise.
Calculate variance for an equally weighted list
For the observations 1, 3 and 5, the mean is 3. Squared deviations are 4, 0 and 4. Their average gives population variance 8/3≈2.666667. The usual sample variance divides their sum by two and is 4. Enter this list in the local calculator to see both conventions. Neither variance equals the range, which is 5−1=4 by a different definition; the matching sample variance and range in this particular example are a numerical coincidence.
Use expectation for a discrete random variable
Suppose X takes values 0, 1 and 2 with probabilities 1/4, 1/2 and 1/4. Its expectation is 0(1/4)+1(1/2)+2(1/4)=1. Its variance is (0−1)²(1/4)+(1−1)²(1/2)+(2−1)²(1/4)=1/2. The probabilities sum to one and supply the weights. No n−1 correction applies to this fully specified distribution. The question is about its mathematical variance, not an estimate from a random sample of observations.
Represent rational weights carefully for a tool check
The small distribution above can be represented by the equally weighted list 0, 1, 1, 2 because those frequencies match its probabilities exactly. The calculator's population variance is then 0.5, which verifies the distribution calculation. Its sample variance, 2/3, has a different interpretation and is not the variance of the specified probability distribution. Expanding rational weights is practical only for modest integer frequencies; arbitrary probabilities should be handled with a direct weighted expectation rather than forced into a large list.
Derive the alternative expectation formula
Expanding the square gives E[(X−μ)²]=E(X²−2μX+μ²). Because μ=E(X) is a constant, this becomes E(X²)−2μ²+μ²=E(X²)−μ². For the example, E(X²)=0²/4+1²/2+2²/4=1.5, so subtracting the squared mean one gives variance 0.5. The identity assumes the relevant expectations exist. It is an algebraic relation, not a guarantee that subtracting two almost equal large floating-point numbers will preserve all useful precision.
Apply shifts and scale factors
For Y=aX+b, the expectation becomes aE(X)+b and the variance becomes a²Var(X). Adding a constant shifts every value and its mean together, leaving all deviations unchanged. Multiplication scales every deviation by a before it is squared. With the probability example and Y=3X+10, the mean is 13 and variance is 9×0.5=4.5. A negative multiplier also squares, so variance cannot become negative simply because the ordering or sign of values is reversed.
Know when a variance is zero or undefined
A finite distribution has variance zero when all probability lies at one value; a constant raw list likewise has population variance zero. Sample variance needs at least two observations because its denominator is n−1. In more general probability models, a finite variance need not exist if the second moment is not finite. The local raw-list calculator does not investigate such theoretical distribution properties. A displayed numerical result should therefore be interpreted within the finite data supplied to it.
State the quantity and the convention
Report whether the answer describes a listed population, estimates a wider population using sample variance, or belongs to a specified probability distribution. Include squared units when the variable has a measurement unit. Standard deviation is the nonnegative square root and has the original unit, while standard error refers to uncertainty in an estimator and is a separate quantity. These labels matter more than reporting additional decimal places, because a precisely rounded answer to the wrong variance definition remains the wrong answer.
Calculator for the supported step
Use this calculator for a finite raw-data list. It reports population and sample variance. For a random variable with unequal outcome probabilities, calculate the probability-weighted expectation separately; the form has no probability-weight input.
Sources and method
OpenStax: mean and standard deviation of a discrete distribution