Lesson #6: Probability Distributions.

Some Introductory Demonstrations

Connecting the CDF and the PDF

Mean and Standard Deviation of a Distribution

A Warm Up

f[x_]:=λ (E^(-λ x))

Integrate[f[x],{x,0,Infinity}]

Integrate[f[x],{x,0,Infinity},Assumptions->Re[λ]>0]

Integrate[f[x] x,{x,0,Infinity},Assumptions->Re[λ]>0]

Plot[Table[f[x] /.λ->lam,{lam,{1,5,10}}],{x,0,2},PlotRange->All]

Manipulate[
Plot[f[x] /.λ->lam,{x,0,2},PlotRange->{0,10 },AxesOrigin->{0,0},Epilog->{Thick,Red,Line[{{(1/lam),0},{(1/lam),10}}]}]
,{lam,(1/2),10}]

Mathematica' s Built In Probability Distributions

?*Distribution*

?PDF

PDF[NormalDistribution[μ,σ],x]

Plot[% /.{μ->0,σ->1},{x,-3,3}]

?CDF

CDF[NormalDistribution[μ,σ],x]

CDF[ExponentialDistribution[λ],x]

Integrate[1-%,{x,0,Infinity},Assumptions->λ>0]

?CharacteristicFunction

CharacteristicFunction[ExponentialDistribution[λ],s]

CharacteristicFunction[ExponentialDistribution[λ],-I s]

D[%,s] /.s->0

Table[D[CharacteristicFunction[ExponentialDistribution[λ],-I s],{s,n}] /.s->0,{n,15}]

CharacteristicFunction[NormalDistribution[μ,σ],s]

((D[%,s] /.s->0)/I)

((D[%55,{s,2}] /.s->0)/(-1))

%-(μ^2)

?Mean

Mean[NormalDistribution[μ,12]]

Mean[{1,2,3.01}]

?ExpectedValue

ExpectedValue[(((#-Mean[ExponentialDistribution[λ]]))^2)&,ExponentialDistribution[λ]]

ExpectedValue[If[x>=10,1,0],ExponentialDistribution[λ],x]

?Variance

?CentralMoment

?RandomReal

dat=Table[RandomReal[ExponentialDistribution[2]],{1000}];
Variance[dat]-Variance[ExponentialDistribution[2]]

There are also Discrete Distributions (PDF means "mass" in this case)

PDF[BinomialDistribution[n,p],k]

?Binomial

ListPlot[Table[{k,PDF[BinomialDistribution[10,p],k]} /.p->1/2,{k,0,10}],Filling->Axis]

Manipulate[
ListPlot[Table[{k,PDF[BinomialDistribution[10,p],k]} /.p->pp,{k,0,10}],PlotRange->{0,0.3},Filling->Axis,PlotStyle->{PointSize[0.05]},FillingStyle->Thickness[0.03]]  
,{pp,0.3,0.7}]

Now Lets Learn Some New Stuff (maybe review):

The Log-Normal Distribution.

Concepts to Understand:

Transformations of Probability Distributions (in this case Log and Exponent).

Usage of Log-Normal for Multiplicative Data.

The Cauchy Distribution

Concepts to Understand:

"Physical" creation of the Cauchy Distribution.

A distribution without an expectation.

Transformation of two probability distirubtions (in this case a quetient of two Normals).

Hazarad Rates

Concepts to Understand

What is the Hazarad Rate.

Examples.

Class Exercise: The Gamma Distribution

The Gamma Density has the "basic form" :

Plot[
{(E^(-x)),            x,               (E^(-x))x}
,{x,0,3},PlotStyle->{Dashed,Dashed,{Black,Thick}}]

We can parametrize it :

Manipulate[
Plot[{(E^(- λ x)),(x^(α-1)),(E^(-x λ))(x^(α-1))},{x,0,5},PlotStyle->{Dashed,Dashed,{Black,Thick}},PlotRange->{0,5}],
{{λ,1},0.5,3},{{α,2},0.5,3}]

Need to "normalize" it (integral on suppurt needs to be 1) :

Integrate[(E^(-x λ))(x^(α-1)),{x,0,Infinity},Assumptions->{α>0,λ>0}]

?Gamma

Integrate[(1/((λ^(-α)) Gamma[α]))(E^(-x λ))(x^(α-1)),{x,0,Infinity},Assumptions->{α>0,λ>0}]

ourPDF[x_]:=((λ^α)/( Gamma[α]))(E^(-x λ))(x^(α-1))

Now lets look at the built in Gamma Distirubtion

?GammaDistribution

PDF[GammaDistribution[α,β],x]

Mean[GammaDistribution[α,β]]

Integrate[ourPDF[x] x,{x,0,Infinity},Assumptions->{α>0,λ>0}]

Exercise 1 :  Exponential Distribution as a special case

Exercise 2: (χ^2) Distribution as a special case

Exercise 3 : Sums of Gamma random variables