Probability distribution (source code)

= Probability distribution
{title2=$\mu_X(B)=\mathbb P(X\in B)$}
{wiki}

= Law of a random variable
{synonym}

= Probability law
{synonym}

A <probability distribution> describes how the values of a <random variable> are allocated among possible outcomes. More precisely, the <law of a random variable> $X$ assigns each <measurable set> $B$ the <probability>
$$
\mu_X(B)=\mathbb P(X\in B).
$$
It is a <probability measure> on the values of $X$. The underlying experiment can be more elaborate than the output: different experiments may produce the same <probability distribution>. The <law of a random variable> retains the probabilities needed to answer questions about that output. https://ocw.mit.edu/courses/6-436j-fundamentals-of-probability-fall-2018/9797310bed4c7f5b5d40d007783eec8d_MIT6_436JF18_lec04.pdf[MIT Fundamentals of Probability, Lecture 4: random variables and their laws]{ref}.

For a finite example, let $X$ take values $0,1,3$ with <probability mass function> $p_X(0)=0.2$, $p_X(1)=0.5$, $p_X(3)=0.3$. Its probabilities sum to one. The event $0<X\leq1$ has probability $0.5$, whereas $0\leq X\leq1$ has probability $0.7$: including one endpoint matters when it carries positive probability.

For a contrasting <random variable> $Y$, choose the <probability density function> $f_Y(y)=2y$ on $0\leq y\leq1$, and zero elsewhere. It integrates to one. Now $\mathbb P(1/4<Y\leq3/4)=\int_{1/4}^{3/4}2y\,dy=1/2$, while every single outcome has probability zero. The <probability density function> can have height $f_Y(0.8)=1.6$: probabilities come from <integrals> over outcome ranges.

\Image[/probability-mass-density-and-cdf.png]
{title=Probability masses and densities accumulate into cumulative distribution functions}
{description=Left: $X$ takes values $0,1,3$ with <probability masses> $0.2,0.5,0.3$, so its <cumulative distribution function> jumps at those values; open and filled markers show the excluded and included heights at a jump. Right: $Y$ has <probability density function> $2y$ on the <interval> $[0,1]$ and <cumulative distribution function> $y^2$ there. The shaded <integral> over $(1/4,3/4]$ and the corresponding <cumulative distribution function> increase both equal $1/2$.}

The <cumulative distribution function> answers all threshold questions for a real <random variable>, regardless of whether there are jumps or a <probability density function>. A <quantile function> reverses the direction of the question: given a cumulative probability level, find a threshold. This connects descriptive summaries to <inverse transform sampling>, which constructs a chosen <probability distribution> from a <uniform distribution>.