Random Variables and their Probability Density and Distribution Functions

Definition - Density Functions - Distribution Functions - Examples

 

The Basic Definition

A random variable, X, is a real numerical valued function defined over a sample space, S. X(s) assigns a real number to every outcome in S.

A discrete random variable has a finite or countably infinite range and is usually defined over a finite or countably infinite sample space.

 

A continuous random variable has a range with an uncountably infinite number of values on the real line and is typically (but not necessarily) defined over an infinite sample space.

Go back.


Probability Density Functions

Discrete Random Variables

The probability distribution function (pdf) for a discrete random variable is a function that assigns a probability to each value of the random variable. The probability that the random variable X assumes for any specific value xi is the value of the pdf for xi and is denoted Px(xi). Collectively, these discrete values xi of X along with their associated probabilities constitute the probability distribution function (pdf). It is the discrete random variable equivalent to the continuous random variable's probability density function.The mathematics of pdfs is based directly on the three axioms of probability.

Basic model:

Value:

Property:

 

Continuous Random Variables

The probability density function (pdf) for a continuous random variable is a function that assigns a probability density to each and every value of the random variable. The probability that the random variable X assumes a value x is undefined because the random variable has an uncountably infinite number of values. This makes the mathematical definition of the pdf a bit more cumbersome than in the discrete random variable case. For a range of the random variable x<xi , probabilities are obtained from the pdf by integration and are denoted as Px(X<x). That is, the probability that the random variable has a value less than xi is equal to the area under the probability density function up to x=xi. The mathematics of pdfs are again based directly on the three axioms of probability.

Basic model:

Property:

Go back.


Cumulative Probability Distribution Functions

The cumulative probability distribution functions for a random variable X is defined as the probability that the random variable is less than or equal to a specific value x. It is important to avoid confusion here when we are talking about discrete random variables. The probability distribution function (pdf) is inherently different from the cumulative probability distribution function.

Model

Features

Discrete

  • piecewise constant

  • limiting value = 1

Continuous

  • continuous

  • limiting value = 1

Go back.


Some Examples

The Binomial pdf

This discrete probability density function models experiments that have only two possible outcomes. The probability of success is p and the probability of failure is q=1-p. The pdf models the probability that we will observe r sucesses and n-r failures in a total of n-trials.

The pdf is readily modeled using MATLAB© and the effect of changing the probability of success p (and consequently the probability of failure q) can be investigated.

The cumulative probability distribution function is also easily calculated and is expressed as:

 

Some MATLAB code and some representative results

%
% Example of a discrete pdf and cpdf
%
% Binomial
clear all;close all;
n=20; % n = number of trials = 20 in this example
p=0.5; % p = probability of success
q=1-p;
% r = number of successes
for r=1:n
nr=round(gamma(n+1)./(gamma(r+1).*gamma(n-r+1)));
P(r)=nr*p^r*q^(n-r);
end
cum_P(1)=P(1);
for r=2:n
cum_P(r)=cum_P(r-1)+P(r);
end
figure
subplot(211);stem(P)
subplot(212);stairs(cum_P)
gtext('n=20, p=0.5, q=1-p=0.8')
gtext('Probability Density Function')
gtext('Cumulative Probability Distribution Function')

 

 

Review questions

  1. For each example above, what is the probability that in 20-trials there are exactly six successes?

  2. Can you locate this information on both the pdf and on the cumulative probability distribution function?

  3. What is the probability that there are at least six successes and how is this calculation related to the graphical results?

  4. Why is the peak value of the pdf different in each of these examples? Can you develop a plausible rational to explain this to someone else?

 

The Gaussian or Normal pdf

The Gaussian pdf is perhaps the most commonly used model - for reasons that will hopefully become clear later. [Why be pessimistic?] - for reasons that will definitely become clear later. Mathematically, it is expressed as:

 

Some (corrected) MATLAB code and some representative results

The MATLAB code is a bit more cumbersome than the last example but does not require any obscure "tricks" of the trade. The m-file below calculates and plots the probability density function only. Computing the cumulative probability distributuion function is a bit more complicated but we could numerically integrate the probability density function if we wanted to. We'll do this in class together if we have time.

 
%
% Example of a continuous pdf
%
% Gaussian or Normal
clear all;close all;
% Define the range for the random variable
dx=.01;x=[-3:dx:3];[m,n]=size(x);
% Define the parameters of the pdf
mux=1;sigx=.5;
% Compute the pdf
a=1/(sqrt(2*pi)*sigx);
for j=1:n
  px1(j)=a*exp([-((x(j)-mux)/sigx)^2]/2);
end
% Change mux
mux=-0.5;
for j=1:n
  px2(j)=a*exp([-((x(j)-mux)/sigx)^2]/2);
end
% Change sigx
mux=1;sigx=1.3;
a=1/(sqrt(2*pi)*sigx);
for j=1:n
  px3(j)=a*exp([-((x(j)-mux)/sigx)^2]/2);
end

% Plot the results
figure
subplot(211);plot(x,px1);grid
hold on;plot(x,px2);hold off
axis([-3 3 0 1]);
gtext('Gaussian pdf for two values of mu_x')
subplot(212);plot(x,px1);grid
hold on;plot(x,px3);hold off
axis([-3 3 0 1]);
gtext('Gaussian pdf for two values of sigma_x')

Review questions

  1. What is the main effect of varying the parameter mu-x? Are there any indications in your results from assignment 1 that suggest there is a corresponding effect in terms of the properties of random signals?

  2. What is the main effect of varying sigma-x? Are there any indications in your results from assignment 1 that suggest there is a corresponding effect in terms of the properties of random signals?

  3. The variables mu-x and sigma-x are directly related to the certain expectations on the random variable X. What are these relationships?

 


Modification of gauss.m to calculate Px(X<x).


Go back.


Return to Random Variables