Basic Models: Continuous Random Variables

There are several continuous random variables which occur routinely, generally used in situations where there is a continuum of possible outcomes   –   a collection of possible outcomes requiring at least an interval of   R   to parameterize.   Anyone wishing to (or needing to) use mathematical statistics should be familiar with at least the following distributions.

Rectangular (or Uniform) Random Variables

Situations where a measured quantity is known to be in a certain interval   [a,b] , with all values of the interval equally likely, are modelled by rectangular random variables.   Let   X   be a random variable with density U[a,b](x)={1baaxb0elsewhere (We use   U   for “uniform”.)

Example:   Position of a Vehicle

The position of a car at a given moment along a stretch of road marked with mile markers from   0   to   20   can be modeled by a random variable with uniform density   U[0,20] .

The main descriptors of a uniform random variable are determined below.

Mean of a Uniform Random Variable

The mean of the uniform random density   U[a,b]   is computed by μ=1baabxdx=1bab2a22=a+b2. That is, the average value of such a rectangular density is the midpoint of the interval of possible values.

Variance of a Uniform Random Variable

The variance of the uniform random density   U[a,b]   will be computed by the   σ2=μ2μ2   trick.   To this end, we have μ2=1baabx2dx=1bab3a33=a2+ab+b23 So that σ2=a2+ab+b23(a+b2)2=(ba)212. The standard deviation is then σ=ba12.

The moment generating function of a uniform random variable can be explicitly computed, and used to obtain the above values.

The Moment Generating Function of a Uniform Random Variable

Let   X   have density   U[a,b] , and   t0 .   We have the following. MX(t)=E[etX]=abetx1badx=1baabetxdx=1ba1tetx|x=ax=b=1t(ba)(etbeta) Thus, for example, dtdtMX(t)=t(betbaeta)(etbeta)t2(ba). We cannot evaluate this directly at   t=0   to obtain   μ .   Instead we use l’Hôpital’s rule to obtain μ=limt0dtdtMX(t)=limt0b2ebta2eat2(ba)=b2a22(ba)=b+a2. This agrees with our previous computation.

Exponential Random Variables

Exponential random variables arise when considering how long it will take for an event to occur   –   the first person to enter a supermarket check-out line, for example.   Or the failure of a piece of equipment.   Or the radioactive decay of a particle.   Their density functions are given by Expλ(x)={λeλxx>00otherwise(λ>0).

The main descriptors of exponential random variables are determined below.

Mean of Exponential Random Variables

The mean of the exponential random density   Expλ   is μ=0xλeλxdx=1λ. That is, the average value of such an exponential random variables is precisely the reciprocal of its parameter   λ .   Thus one often sees exponential random variables written as   Exp1μ .

Variance of Exponential Random Variables

The variance of the exponential random density   Exp1μ   will be computed by the   σ2=μ2μ2   trick.   To this end, we have μ2=0x21μexμdx=2μ2. Thus σ2=2μ2(μ)2=μ2. The standard deviation is then σ=μ=1λ.

Example:   The average waiting time for calls at a help line is five minutes.   What is the probability that a call will arrive in the next three minutes?   What is the probability that no calls will arrive in the next eight minutes?

With   μ=5 , we have P(0X<3)=0315exp(x5)dx=1exp(35)0.4512 and P(X>8)=815exp(x5)dx=exp(85)0.2019. Note that this last computation can be obtained by P(X>8)=1P(X8)=10815exp(x5)dx10.7981=0.2019.

Computing Probabilities for Exponential Random Variables with Spreadsheets

Computations of density and distribution functions for exponential random variables are easily performed within spreadsheets.   The important thing to remember is that EXP means the exponential function, so a new term must be used.   This is EXPONDIST.   Thus we have “=EXPONDIST(x, λ, 0)” yields the density function   Expλ(x)=λexp(λx) , while “=EXPONDIST(x, λ, 1)” gives the distribution function   0xλexp(λt)dt=1exp(λx) .

This can be seen in the following spreadsheet.   A value of   λ   ( [12,2] ) is given in cell B1, and a value of   x   ( [1,5] ) is given in cell B2.   If   X   represents an exponential random variable with   λ   the value in B1, we display several computations.   In cell E1 you will find the value of the density function given by “=EXPONDIST(B2, B1, 0)”, and in cell E2 you will find a check of this with “=B1*EXP(-B1*B2)”.   Notice that the cells E1 and E2 have been identically colored so as to be easily compared.   In E3 you will find the probability   P(X<B2)   given by “=EXPONDIST(B2, B1, 1)”, in cell E4 you will find the probability   P(XB2)   given by “=1-EXPONDIST(B2, B1, 1)”, and in E5 a check that this last can be obtained by “=EXP(-B2*B1)”.   Cells E4 and E5 have been identically colored so as to be easily compared.

Click here to open a copy of this so you can experiment with it. You will need to be signed in to a Google account.

Normal Random Variables

Normal random variables are an important class of continuous random variables whose value will become apparent shortly.   Consider the continuous random variable   Za,b   (for   aR , bR+ ) whose density function is given by norma,b(x)=1b2πexp(12(xab)2), with cumulative distribution 1b2πxexp(12(tab)2)dt.

The distribution   Z0,1 , with density Z0,1(x)=12πexp(x22) is commonly called standard normal.   Normal random variables may have subscripts suppressed (i.e. denoted by   Z ) if   a   and   b   are understood.

For these to truly be random variables, we need that the associated densities are non-negative and have integrals 1b2πexp(12(tab)2)dt=1. That the densities are actually positive follows from the fact that exponential functions are always positive, and that the integral   =1   follows from the following rather advanced fact. Fact:   exp(x2)dx=π , found, for example, at https://en.wikipedia.org/wiki/Gaussian_integral.

A derivation, and several consequences, of the fact that   exp(x2)dx=π

First we show why the integral has the value claimed.

To this end, let   V=exp(x2)dx .   Then V2=exp(x2)dxexp(y2)dy=R2exp((x2+y2))dA=02π(0rexp(r2)dr)dθ=2π(120exp(u)du)=π. So in fact   V=π , and we have established the basic integral equality.

Now, let t=x2 in the integral equality exp(t2)dt=π. We get 12exp(x22)dx=π or 12πexp(u22)du=1. This shows that   Z0,1   is a probability density.

Finally, make a further change of variable   u=sab   in the last equality above.   The equality is re-expressed as 1b2πexp(12(sab)2)ds=1. We see that every one of the   Za,b   is also a probability density.

The main descriptors of a normal random variable are determined below. We will see that   a=μ   and   b=σ .   Because of this we will henceforth refer to   Zμ,σ   instead of   Za,b(x)   when values of the parameters are unknown.

The mean of   Za,b   is   a .

Here we first notice that the mean of a standard normal variable is   computed by t12πexp(12t2)dt. Since the integrand is an odd function of   t , this integral evaluates to   0 .

To compute the mean of non-standard normal variable   Za,b ,   we integrate t1b2πexp(12(tab)2)dt. To evaluate this, we make the change of variable   s=tab   and see that the integral becomes (bs+a)12πexp(12s2)ds. Splitting this into two integrals bs12πexp(12s2)ds (which evaluates to   0 ), and a12πexp(12s2)ds (which evaluates to   a ), we have (bs+a)12πexp(12s2)ds=a. That is, the mean of   Za,b   is   a .

The standard deviation of   Za,b   is   b .

Here we first notice that the mean of a standard normal variable is   computed by t12πexp(12t2)dt. Since the integrand is an odd function of   t , this integral evaluates to   0 .

Example:   The moment generating function of   Zμ,σ   is   exp(μt+12σ2t2) .

To see this, we first determine the moment generating function of   Z0,1 .   A change of variables will allow us to then find the moment generating function of   Zμ,σ .

To this end, MZ0,1(t)=etx12πe12x2dx=12πe12(x22xt+t2t2)dx=e12t212πe12(xt)2dx=e12t2. and, with   W=Zμ,σ , MW(t)=etx1σ2πe12(xμσ)2dx=1σ2πe12((xμσ)22tx)dx=1σ2πe12((xμσ)22σt(xμσ)+(σt)22μtσ2t2)dx=eμt+12σ2t212πe12((xμσ)σt)2dx=eμt+12σ2t2.

What follows is a selection of probability computations with normal random variables.   These should be examined as they are standard and will be used later without hesitation.

Computations with Normal Densities

Computations with a Standard Normal Variable

For a standard normal variable   Z0,1 , we have P(Z0,1<a)=a12πexp(x22)dx=P(Z0,1a) (as the probability that   Z0,1   takes on precisely any given value is zero).   Geometrically, this is the area under the curve   y=12πex22   for   x<a .   This is shown in the diagram below.

area under standard normal curve from -infty to a

P(Z0,1<a)=   shaded area

Since the function   f(x)=12πex22   is even (i.e.   f(x)=f(x) ), we have P(Z0,1>a)=a12πexp(x22)dx=a12πexp(x22)dx=P(Z0,1a)=1P(Z0,1a). This is shown in the following illustration.

area under standard normal curve from a to +infty area under standard normal curve from -infty to -a area under standard normal curve from -infty to a
Area 1 Area 2 Area 3

Area 1   =   Area 2   =   1 – Area 3

We can use these to compute   P(a<Z0,1<b)   for arbitrary   a<b . P(a<Z0,1<b)=ab12πexp(x22)dx=b12πexp(x22)dxa12πexp(x22)dx=P(Z0,1b)P(Z0,1a) Similar is the computation of   P(|Z0,1|>a) : P(|Z0,1|>a)=1P(|Z0,1|a)=1P(|Z0,1|a)=2P(Z0,1<a). These can be seen in the diagram below.

area under standard normal curve from -infty to -a and then from a to +infty area under standard normal curve from -a to a area under standard normal curve from -infty to -a
Area 4 Area 5 Area 6

Area 4   =   1 – Area 5   =   2 ⋅ Area 6

The first of these computations is obtained in spreadsheets using a command such as “=NORMSDIST( )” .   The others usually require the type of arithmetic indicated above.   in the following spreadsheet we you see in cells B1 and B2 two randomly generated decimal value between   1   and   1 , with the first ( a ) negative and the second ( b ) positive.   In cell E1 we use the command “=NORMSDIST(A1)” to generate   P(Z0,1<a) .   In cell E2 we use the command “=NORMSDIST(-A2)” to generate   P(Z0,1>b) .   Note that this is the same as the value in E3 obtained using “=1-NORMSDIST(A2)” .   In cell E4 we use the command “=NORMSDIST(A2)-NORMSDIST(A1)” to generate   P(a<Z0,1<b) .   In cell E5 we use the command “=2*(1-NORMSDIST(A2))” to generate   P(|Z0,1|>b) .   The spreadsheet is not performing any sort of approximation of the integral, but rather is accessing a stored table of values.  . Standard normal variables are of great enough importance that values of this awkward integral were computed using approximation methods from calculus and recorded in massive books.   Many libraries still have these books on shelves.   For our purposes, you can obtain values of the standard normal cumulative distribution function from the tool attached to this section.

Click here to open a copy of this so you can experiment with it. You will need to be signed in to a Google account.

Computations with Other Normal Variables

Computations with non-standard normal variables, similar to those for standard normal variables, are produced with linear change of variable.   Noting that with the change of variable   s=tμσ   the integral AB1σ2πexp(12(tμσ)2)dt becomes AμσBμσ12πexp(12s2)ds, we interpret this as P(A<Zμ,σ<B)=P(Aμσ<Z0,1<Bμσ).

Just as for standard normal variables there are spreadsheet commands to determine values of the cumulative distribution, so too do such exist for other normal variables.   Typically a command such as “=NORMDIST( )” exists in a spreadsheet.   This command returns either the density or distribution function for a prescribed normal variable, as per request.   It requires that one enter the mean and standard deviation of the normal variable, and choose the output.   In the following spreadsheet you will see in cell B1 a randomly generated number between   5   and   5 , in B2 a randomly generated number between   2   and   2 , and in cell B3 a randomly generated number between   0.5   and   2 .   In E1 you will see a number generated by the command “=NORMDIST(A1, A2, A3, 1)” which is   P(ZA2,A3<A1) .   The command “=NORMDIST(A1, A2, A3, 0)” returns the density function value (so that the 0/1 in the last place indicates whether or not the density function is integrated   –   1 means yes and 0 means no).   normA2,A3(A1) .   A verification of the computational trick mentioned above is shown in cell E2 where you will find a number generated by the command “=NORMSDIST((A1-A2)/A3)” .   As observed in the discussion of the command “=NORMDIST”, this is   P(Z0,1<A1A2A3) .   Note that it is exactly the same as the value in E1.   (Also observe that we use subscripts “m” and “s” for   μ   and   σ , as Google sheets do not allow easy creation of subscripts.)

Click here to open a copy of this so you can experiment with it. You will need to be signed in to a Google account.

Two other classes of continuous random variables are included.   These will also be important in later discussions, although nowhere near as important as normal random variables.   The introductions below are brief at best, and such random variables will be discussed later as necessary.

The   χ2   class

The   χ2   (read “chi-squared”) with   k   degrees of freedom has density function is given by χ2(x;k)=12k/2Γ(k2)xk21ex2, where   Γ(x)   is the important mathematical function Γ(x)=0tx1etdt. The corresponding distribution function is γ(k2,x2)Γ(k2), where γ(s,x)=0xts1etdt. Plots of both density and distribution functions are shown below for   k=1,2,3,5,10 .

graphs of chi-squared for parameter values 1, 2, 3, 5, and 10 graphs of chi-squared distribution functions for parameter values 1, 2, 3, 5, and 10
densities distributions

The mean of   χ2(x;k)   can be explicitly calculated to be   k , and the variance calculated to be   2k .   The moment generating function can be explicitly determined for this family of densities: MGFχ2(x;k)(t)=(12t)k/2.

Student’s   t   distributions

Student’s   t   distribution has density function T(x;ν)=Γ(ν+12)νπΓ(ν2)(1+x2ν)ν+12 and distribution function 12+xΓ(ν+12)2F1(12,ν+12;32;x2ν)νπΓ(ν2), where   2F1   is a hypergeometric function.   Random variables with these density functions are often used to approximate the standard normal, and in the applet below (not currently functional) the reader can control   ν   from   1   to   25 .   It is clear that as   ν   increases the approximation to the standard normal (also plotted) improves.   In fact, the limit as   ν+   is precisely the standard normal.

graphs of Student-T functions for parameter values 3 and 5 compared to graph of standard normal

graphs of Student’s   t   functions for   ν=3   and   ν=3 , compared to graph of standard normal


var fcnJs, negText, test, riemann, left, right, brd, slider1, tid;
function graph(){
// You can't use 'macro parameter character #' in math mode(‘#graphplaceholder’).prepend(‘

‘);

fcnJS = “1/Math.sqrt(2*Math.PI)*Math.pow(Math.E, (-1/2*Math.pow(x,2)))”;
negTest = new Function(‘x’, ‘return ‘+fcnJS+’;’);
// test = function(x){
// return -1*negTest(x);
// }
test = new Function(‘x’, ‘return -1*(‘+fcnJS+’);’);

// riemann = function(x){
// return 0.99*(eval(fcnJS));
// }
riemann = new Function(‘x’, ‘return Math.max((‘+fcnJS+’)-0.006, 0.000001);’);

left = -5;
right = 5;

Tdist = new Function(‘x’, ‘return jStat.studentt.pdf(x, slider1.Value()/100);’);

maxYValuept = (JXG.Math.Numerics.fminbr(negTest, [left, right]) );
minYValuept = (JXG.Math.Numerics.fminbr(test, [left, right]));
console.log(minYValuept + ” ~~~~ ” + maxYValuept);
maxYValue = Math.max(negTest(maxYValuept), negTest(left), negTest(right), negTest(minYValuept));
minYValue = Math.min(negTest(minYValuept), negTest(left), negTest(right), negTest(minYValuept));

minV = 0 – Math.abs(minYValue – Math.abs(0.3*maxYValue));

console.log(minYValue + ” ~~~~ ” + maxYValue);

//brd = JXG.JSXGraph.initBoard(‘graph’,{boundingbox:[(1.1*0-0.1*right), (1.1*maxYValue – 0.1*0), (1.1*right – 0.1*0), (1.3*0 – 0.3*maxYValue)], showCopyright:false, axis:true, copyRight:false});
brd = JXG.JSXGraph.initBoard(‘graph’,{boundingbox:[(-5.2), (1.1*maxYValue – 0.1*0), (5.2), (1.3*0 – 0.3*maxYValue)], showCopyright:false, axis:true, copyRight:false});
jsxFcn = brd.create(‘functiongraph’, [negTest, left, right], {strokeWidth:3});
//slider1 = brd.createElement(‘slider’, [[-4,(1.15*0 – 0.15*maxYValue)],[4,(1.15*0 – 0.15*maxYValue)],[left*100, (left*100+right*100)/2, right*100]],{withTicks:true,withLabel:false});
slider1 = brd.createElement(‘slider’, [[-4,(1.15*0 – 0.15*maxYValue)],[4,(1.15*0 – 0.15*maxYValue)],[100, 100, 2500]],{withTicks:true,withLabel:false,snapWidth:100});
//riemannFill = brd.create(‘riemannsum’,[riemann, 100, ‘trapezoidal’, left, function(){return slider1.Value()/100;}],
//riemannFill = brd.create(‘riemannsum’,[riemann, 100, ‘lower’, left, function(){return slider1.Value()/100;}],
// {strokeColor:’pink’, strokeWidth:1, fillColor:’pink’, highlightFillColor:’pink’, highlightFillOpacity:0.4});
jsxFcn2 = brd.create(‘functiongraph’, [Tdist, left, right], {strokeWidth:3, strokeColor:”red”});
tid = setInterval(function(){
You can't use 'macro parameter character #' in math modeA\,=\,”+((slider1.Value()/100).toFixed(2))+”$”);
MathJaxRefresh(“aValue”);
}, 1000);

}
JXG.Curve.prototype.highlight = function(){
//overrides highlighting of circles
}
document.ready=graph;

The means of these are all   0 , and the variance is   νν2   as long as   ν>2 .   The moment generating function is undefined.