R Variables
R Variables
Department of Statistics
Universidad Carlos III de Madrid
Random variables
Statistics — 2013–2014
A random variable assesses a real number to each possible outcome of a
random experiment.
Definición 1. Given a random experiment with associated sample space E
(and associated probability P ), a random variable X is a mapping from the
sample space E into R. Formally, it must satisfy the mathematical property
of being measurable.
That is, a random variable is a mapping
X : E −→ R .
For any set of real numbers B, its inverse image, given by X −1 (B) = {e ∈
E : X(e) ∈ B}, is an event associated with the random experiment.
Associated with a random variable X, it is possible to define a probability
whose sample space is R and the events are subsets of R. That is, the mapping
PX that associates each set of real numbers B with the value PX (B) =
−1
P X (B) is a probability. We will usually write P (X ∈ B) instead of
PX (B) and we will refer to it as the probability that the random variable X
lies in (or assumes a value in) B.
1
Continuous random variables, density mass function. The set of
values that a continuous random variable can assume contains an interval of
real numbers. The distribution of a continuous random variable is determined
R +∞ mass function is a mapping f : R −→
by its density mass function. A density
R that satisfies f (x) ≥ 0 and −∞ f (x)dx = 1. If f is the density mass
function of X, then for any set of real numbers B, it holds
Z
P (X ∈ B) = f (x)dx,
B
Rb
specifically, given a, b ∈ R, we have P (a ≤ X ≤ b) = a f (x)dx.
Notice that the probability that a continuous random variable assumes
any fixed real value is 0. That is, if X is continuous and a ∈ R, then P (X =
a) = 0.
lı́mx→−∞ F (x) = 0;
lı́mx→+∞ F (x) = 1.
The cumulative distribution function of the random variable X is defined
for every x ∈ R as F (x) = P (X ≤ x).
If X is discrete, the set of all possible values that it assumes is given by
{x1 , x2 , . . .}, and its probability mass function is p, then
X
F (x) = p(xi ) .
xi ≤x
2
Given a, b ∈ R with a < b, it is possible to express the probability that X
lies in any interval with a and b as extreme values in terms of the cdf of X.
E[aX + b] = aE[X] + b;
var[X] = E (X − E[X])2 .
3
Commonly, the variance of a random variable (population) is denoted by
2 2
σ or σX to make explicit reference to the random variable. The standard
deviation
p of a random variable is the (positive) square root of its variance,
var[X], it is denoted by σ or σX .
var[b] = 0;
var[aX] = a2 var[X];
var[aX + b] = a2 var[X].
Skewness: Skew = µ3 /σ 3 ;
Kurtosis: Kurt = µ4 /σ 4 − 3 .
FY (y) = P (g(X) ≤ y) = P (X ∈ Ay ) ,
where Ay = {x : g(x) ≤ y}. It often happens that the sets Ay are simple to
describe (e.g. when g is monotonic), and then we can compute their proba-
bility just by using our knowledge of the distribution of X. In those cases,
it is highly recommendable to develop further the expression above. If we
are interested in the density mass function of Y , we can finally derive with
respect to y.
4
If X is discrete, it holds
X
FY (y) = P (g(X) ≤ y) = pX (xi ) ;
g(xi )≤y
X
pY (y) = P (g(X) = y) = pX (xi ) .
g(xi )=y
Random vectors
In many situations we are interested in more than one feature (variable)
associated with the same random experiment. A random vector is a mapping
from a sample space E into Rn . A bivariate random vector maps E into R2 ,
(X, Y ) : E −→ R2 .
5
joint cumulative distribution function:
Z x0 Z y0
F (x0 , y0 ) = P (X ≤ x0 , Y ≤ y0 ) = f (x, y)dydx .
−∞ −∞
We have further
∂ 2 F (x, y)
f (x, y) = .
∂x∂y
6
Discrete variables. Given X and Y two discrete random variables with
p(x, y) as joint probability mass function
P (X = x0 , Y = y) p(x0 , y)
p(y|x0 ) = P (Y = y|X = x0 ) = = .
P (X = x0 ) pX (x0 )
P (X = x, Y = y0 ) p(x, y0 )
p(x|y0 ) = P (X = x|Y = y0 ) = = .
P (Y = y0 ) pY (y0 )
f (x0 , y)
f (y|x0 ) = .
fX (x0 )
f (x, y0 )
f (x|y0 ) = .
fY (y0 )
7
Discrete variables: X and Y are independent if for all x, y any of the
following conditions is fulfilled
p(y|x) = pY (y)
p(x|y) = pX (x)
p(x, y) = pX (x)pY (y) .
8
Covariance. The covariance is a measure of the linear relation between
two variables,
Cov(X, Y ) = E (X − E[X])(Y − E[Y ]) = E[XY ] − E[X]E[Y ] .