A random variable X is a function from Ω (the event space) to the set of real numbers.
if Ω is finite or countable, then X is a discrete random variable. If not X is a continuous random variable. This is a really wonderful definition, as it shows that random variables aren't variables at all and they aren't random either.

A discrete random variable is determined by its distribution function, f. This is a function such that f(k)=probability that X takes the value k (usually written P(X=k)).

f must have the obvious properties: f is positive, and Σf(k)=1, for k ranging over the range of X.

The expectancy of X (also called mean) is E(X)=ΣkP(X=k). Note that the mean might be infinite.
We also define the variance to be σ^{2}=E((X-E(X))^{2}.

Before evaluating this, you may wish to convince that expectancy is linear : if a,b constants, X,Y random variables, then E(aX +bY)=a E(X) + b E(Y) (provided all these expectancies exist of course). Also E(a)=a

σ^{2}=E(X^{2} -2XE(X)-E(X)^{2})
=E(X^{2})-2(E(X))^{2}+(E(X))^{2} (by linearity of expectancy)
=E(X^{2})-E(X)^{2}, which is a useful formula for calculating variances.

finally, an example: the

Poisson distribution. here we have P(X=k) = e

^{-λ}λ

^{k}/k!

λ is the parameter of the distribution, k is a positive integer.

Then E(X) = Σ^{∞}_{k=0}k e^{-λ}λ^{k}/k!
= e^{-λ}Σ^{∞}_{k=1}λ^{k}/(k-1)!
= λe^{-λ}Σ^{∞}_{k=1}λ^{k-1}/(k-1)!
= λe^{-λ}Σ^{∞}_{k=0}λ^{k}/k!
= λe^{-λ}e^{λ}
= λ

Thus the Poisson distribution has

mean λ. you may wish to check for yourselves that its variance is also λ

As stated previously, continuous random variables are what happens when we have an uncountable event space. it seems natural to replace the sum by an integral. The distribution function F(x) is defined to be P(X≤x)=∫_{-∞}^{x}f(x)dx , where f is the probability density function (noted pdf). For all this to work we need the obivous properties:

- f positive
- ∫
_{-∞}^{∞}f(x)dx=1

It is natural enough to define mean and variance in a similar way : E(X)=∫_{-∞}^{∞}xf(x)dx, the definition of the variance is the same. Linearity of expectancy follows from linearity of the integral. As before, the expectancy may not exist. Note that discrete random variables are just continuous ones, whose distribution function is a step function.

To round things off, another example: the Cauchy distribution. (Yes this is the same Cauchy as the Cauchy-Argand diagram, Cauchy's Inequality, Cauchy integral formula etc... Nosy little bugger couldn't keep his nose out of any area of maths). The density function of the cauchy distribution is f(x)= a/π(x^{2}+a^{2}), where a is a non-zero real parameter.

∫_{-∞}^{∞}f(x)dx
=(1/a^{2}π)∫_{-∞}^{∞}adx/(1+(x/a)^{2})
=(1/π)∫_{-∞}^{∞}dy/(1+y^{2}) by change of variables y = x/a
=(1/π)[arctan y ]^{∞}_{-∞}
= 1

f satisfies the rules to be a pdf. The fun starts if you try to calculate the mean:
∫

_{-∞}^{∞}xf(x)dx
=(1/2π)

∫_{-∞}^{∞}2axdx/(x

^{2}+a

^{2})
=(a/2π)[ln(x

^{2}+a

^{2})]

^{∞}_{-∞}
Which as you can see does not have a

limit. Hooray !! A distribution with an

undefined mean !

Source: What i can remember of my Part IA Probability course, which i have an exam on in 2 days