Cumulative Distribution Function ================================ The cumulative distribution function brings the discrete and continuous RV's toegether. For a RV $X$ the cumulative distribution function (often called the distribution function) is defined as: .. math:: F_X(x) = \P(X\leq x) Note that $x\in\setR$ even in case $X$ is a discrete RV. We have: .. math:: F_X(x) = \begin{cases} \sum_{k=-\infty}^{\lfloor x\rfloor} p_X(k) &\text{Discrete $X$}\\ \int_{-\infty}^{x} f_X(y)\, dy &\text{Continuous $X$} \end{cases} Below a probability mass function $p_X$ is plotted and the corresponding $F_X$. .. ipython:: python :suppress: from matplotlib.pylab import * pX = array([0,0,0,0,1,2,4,5,7,6,5,3,1,0,0,0]) pX = pX / sum(pX) x = arange(len(pX))-7 cpX = cumsum(pX) subplot(211) title(r"Probability Mass Function") stem(x,pX) subplot(212) title(r"Cumulative Distribution Function") step(x, cpX, where='post') @savefig discrete_cdf.png show() And a plot of a probability density function and its corresponding cumulative distribution function. .. ipython:: python :suppress: # # I am cheating by calculating things for a sampled function... # ONLY LOOK AT THE PLOTS... # from matplotlib.pylab import * x = linspace(-8, 8, 1000) pX = piecewise(x, [x<-4, logical_and(x>=-4, x<4), x>=4], [0, lambda x: 16-x**2, 0]) pX = pX / sum(pX) cpX = cumsum(pX) subplot(211) title(r"Probability Density Function") plot(x,pX) subplot(212) title(r"Cumulative Distribution Function") step(x, cpX, where='post') @savefig continuous_cdf.png show() The cumulative distribution function follows from the probability density function by integration. We can go the other way as well: .. math:: f_X = \frac{d}{dx} F_X With some mathematical leniency we could say that this also holds for a discrete random variable.