What This Calculator Does
This tool computes the variance and standard deviation of a discrete random variable from its probability distribution. You supply each possible outcome (\(x_i\)) and the probability of that outcome (\(p_i\)), and the calculator returns the variance Var(X), the mean \(\mu\), the expected value of \(X^2\), and the standard deviation \(\sigma\). Variance measures how spread out the outcomes are around the mean — a small variance means outcomes cluster near the average, while a large variance means they are widely dispersed.
How to Use It
Enter the outcomes as a comma-separated list in the first box (for example 1, 2, 3). Enter the matching probabilities in the same order in the second box (for example 0.2, 0.5, 0.3). The probabilities should sum to 1; the calculator reports \(\sum p_i\) so you can verify this. Click calculate to see the variance and related statistics.
The Formula Explained
The variance uses the convenient computational form:
$$\operatorname{Var}(X) = \sum p_i x_i^{2} - \left(\sum p_i x_i\right)^{2}$$Here \(\sum p_i x_i\) is the mean \(\mu = E[X]\), and \(\sum p_i x_i^{2}\) is \(E[X^2]\). Subtracting the square of the mean from \(E[X^2]\) gives the variance. This is algebraically identical to the definition \(\operatorname{Var}(X) = \sum p_i (x_i - \mu)^2\) but is easier to compute in one pass. The standard deviation is simply \(\sigma = \sqrt{\operatorname{Var}(X)}\).
Worked Example
Suppose X takes values 1, 2, 3 with probabilities 0.2, 0.5, 0.3. The mean is $$\mu = 1(0.2) + 2(0.5) + 3(0.3) = 0.2 + 1.0 + 0.9 = 2.1.$$ $$E[X^2] = 1(0.2) + 4(0.5) + 9(0.3) = 0.2 + 2.0 + 2.7 = 4.9.$$ So $$\operatorname{Var}(X) = 4.9 - 2.1^{2} = 4.9 - 4.41 = 0.49,$$ and \(\sigma = \sqrt{0.49} = 0.7\).
FAQ
Do the probabilities have to add to 1? Yes, for a valid distribution. The calculator shows \(\sum p_i\) so you can confirm. If it isn't 1, your results will be inaccurate.
What is the difference between variance and standard deviation? Variance is in squared units; standard deviation is its square root, expressed in the same units as X, which makes it easier to interpret.
Can variance be negative? No. Mathematically variance is always \(\geq 0\). A negative result indicates a data-entry error in the probabilities.