({{, (RefLink[Probability, paclet:ref/Probability])[pred,x\[Distributed]dist] 
gives the probability for an event that satisfies the predicate pred under the assumption that x follows the probability distribution dist.}, {, (RefLink[Probability, paclet:ref/Probability])[pred,x\[Distributed]data]
gives the probability for an event that satisfies the predicate pred under the assumption that x follows the probability distribution given by data.}, {, (RefLink[Probability, paclet:ref/Probability])[pred,{(Subscript[x, 1]),(Subscript[x, 2]),…}\[Distributed]dist]
gives the probability that an event satisfies pred under the assumption that {(Subscript[x, 1]),(Subscript[x, 2]),…} follows the multivariate distribution dist.}, {, (RefLink[Probability, paclet:ref/Probability])[pred,{(Subscript[x, 1])\[Distributed](Subscript[dist, 1]),(Subscript[x, 2])\[Distributed](Subscript[dist, 2]),…}]
gives the probability that an event satisfies pred under the assumption that (Subscript[x, 1]), (Subscript[x, 2]), … are independent and follow the distributions (Subscript[dist, 1]), (Subscript[dist, 2]), ….}, {, (RefLink[Probability, paclet:ref/Probability])[(Subscript[pred, 1])\[Conditioned](Subscript[pred, 2]),…]
gives the conditional probability of (Subscript[pred, 1]) given (Subscript[pred, 2]).}})

OpenersNotesSection(Spacer1)Details and Options

x\[Distributed]dist can be entered as x (Key0[esc]) dist (Key0[esc]) dist or x∖[Distributed]dist.

(Subscript[pred, 1])\[Conditioned](Subscript[pred, 2]) can be entered as (Subscript[pred, 1]) (Key0[esc]) cond (Key0[esc]) (Subscript[pred, 2]) or (Subscript[pred, 1])∖[Conditioned](Subscript[pred, 2]).

For a continuous distribution dist, the probability of pred is given by ∫(RefLink[Boole, paclet:ref/Boole])[pred]f[x]dx where f[x] is the probability density function of dist and the integral is taken over the domain of dist.

For a discrete distribution dist, the probability of pred is given by ∑(RefLink[Boole, paclet:ref/Boole])[pred]f[x] where f[x] is the probability density function of dist and the summation is taken over the domain of dist.

For a dataset data, the probability of pred is given by (RefLink[Sum, paclet:ref/Sum])[(RefLink[Boole, paclet:ref/Boole])[pred],{x,data}]/(RefLink[Length, paclet:ref/Length])[data].

Univariate data is given as a list of values {(Subscript[v, 1]),(Subscript[v, 2]),…} and multivariate data is given as a list of vectors {{(Subscript[v, 11]),…,(Subscript[v, 1m])},{(Subscript[v, 21]),…,(Subscript[v, 2m])},…}.

(RefLink[Probability, paclet:ref/Probability])[pred,{(Subscript[x, 1])\[Distributed](Subscript[dist, 1]),(Subscript[x, 2])\[Distributed](Subscript[dist, 2])}] corresponds to (RefLink[Expectation, paclet:ref/Expectation])[Probability[pred,(Subscript[x, 2])\[Distributed](Subscript[dist, 2])],(Subscript[x, 1])\[Distributed](Subscript[dist, 1])] so that the last variable is summed or integrated first.

(RefLink[N, paclet:ref/N])[Probability[…]] calls (RefLink[NProbability, paclet:ref/NProbability]) for probabilities that cannot be evaluated symbolically.

The following options can be given:

OpenersPrimaryExamplesSection(Spacer1)Examples  (102)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Compute the probability of a simple event:

Probability[x≤3,x\[Distributed]NormalDistribution[]]

Probability[x≤3,x\[Distributed]PoissonDistribution[μ]]

Probability[x≤1/2∧y≤1/3,{x,y}\[Distributed]DirichletDistribution[{1,4,5}]]

Probability[x≤2∧y≤3,{x,y}\[Distributed]MultivariatePoissonDistribution[1,{2,3}]]

Compute the probability of nonlinear and logical combination of inequalities:

Probability[(((x-1))^2)≤3x,x\[Distributed]NormalDistribution[]]

Probability[(x^2)>3∨Abs[x]<1,x\[Distributed]{1,2,3}]

Probability[(x^2)>3∨Abs[x]<1,x\[Distributed]ExponentialDistribution[λ]]

Probability[(x^2)+(y^2)<1/4∧x+y<6/7,{x,y}\[Distributed]DirichletDistribution[{2,3,4}]]

Plot3D[PDF[DirichletDistribution[{2,3,4}],{x,y}],{x,0,3/5},{y,0,3/5},RegionFunction->Function[{x,y,z},x^2+y^2<1/4&&x+y<6/7],Mesh->None,PlotStyle->Opacity[0.7],Filling->Bottom]

Compute a conditional probability:

Probability[(x^2)>1\[Conditioned]x>1/2,x\[Distributed]LaplaceDistribution[0,1/2]]

Probability[x+(y^2)+(z^2)<(3/10)\[Conditioned](x==1/7∧y==1/4),{x,y,z}\[Distributed]DirichletDistribution[{1,3,4,7}]]

OpenersExampleSection1(Spacer1)Scope  (29)

OpenersExampleSubsection0(Spacer1)Basic Uses  (9)

Compute the probability of an event in a continuous univariate distribution:

Probability[3<x<5,x\[Distributed]NormalDistribution[]]

Discrete univariate distribution:

Probability[1<x<7,x\[Distributed]PoissonDistribution[1]]

Continuous multivariate distribution:

Probability[0<x<5/2&&1/2<y<8,{x,y}\[Distributed]DirichletDistribution[{1,2,3}]]

Discrete multivariate distribution:

Probability[1<x<5/2&&5<y<8,{x,y,z}\[Distributed]MultinomialDistribution[10,{1/3,1/2,1/6}]]

Find the probability of an event in a distribution specified by a list:

r=RandomVariate[NormalDistribution[],1000];

Probability[x^2+3x<11,x\[Distributed]r]

Compute the probability using independently distributed random variables:

Probability[1<x<5&&-3<y<8,{x\[Distributed]ExponentialDistribution[1],y\[Distributed]NormalDistribution[]}]

N[%]

Find the conditional probability with general nonzero probability conditioning:

Probability[x<2\[Conditioned]1/2<x^2<5,x\[Distributed]ExponentialDistribution[λ]]

Plot[%,{λ,0,5}]

Discrete univariate distribution:

Probability[x^2>12\[Conditioned]x>2,x\[Distributed]PoissonDistribution[λ]]

Plot[%,{λ,0,10}]

Multivariate continuous distribution:

Probability[x+y<7/10\[Conditioned]y>1/3,{x,y}\[Distributed]DirichletDistribution[{1,3,4}]]

Multivariate discrete distribution:

Probability[x+y<5\[Conditioned]z>2,{x,y,z}\[Distributed]MultinomialDistribution[10,{1/3,1/2,1/6}]]

Compute the conditional probability with a zero-probability conditioning event:

Probability[x+y^2<3/10\[Conditioned](x==1/7),{x,y}\[Distributed]DirichletDistribution[{1,3,4}]]

Apply (RefLink[N, paclet:ref/N])[Probability[…]] to invoke (RefLink[NProbability, paclet:ref/NProbability]) if symbolic evaluation fails: »

f[x_?NumericQ]:=x^3

Probability[f[x]<1,x\[Distributed]NormalDistribution[]]

N[%]

NProbability[f[x]<1,x\[Distributed]NormalDistribution[]]

With no (RefLink[Assumptions, paclet:ref/Assumptions]), conditions are generated:

Probability[x<a,x\[Distributed]UniformDistribution[{2,8}]]

With (RefLink[Assumptions, paclet:ref/Assumptions]), a result valid under the given assumptions is returned:

Probability[x<a,x\[Distributed]UniformDistribution[{2,8}], Assumptions-> 5<a<7]

Assuming[5<a<7,Probability[x<a,x\[Distributed]UniformDistribution[{2,8}]]]

Use nonlinear predicates and arbitrary logical combinations:

Probability[(x^2<5&& (2x+3)<5)||(x^3+x>11),x\[Distributed]ExponentialDistribution[2]]

Calculate the probability of an event for a time slice of a Poisson process:

Probability[x[t]^2+x[t]<34,x\[Distributed]PoissonProcess[μ]]

OpenersExampleSubsection1(Spacer1)Quantity Uses  (3)

Probability of events specified using (RefLink[Quantity, paclet:ref/Quantity]):

Probability[Quantity[x,"Meters"]<Quantity[3,"Feet"],x\[Distributed]LogNormalDistribution[2,3]]

Probability involving (RefLink[QuantityDistribution, paclet:ref/QuantityDistribution]):

Probability[x>Quantity[3,"Meters"],x\[Distributed]QuantityDistribution[WeibullDistribution[2,3],"Yards"]]

Conditional probability specified using (RefLink[Quantity, paclet:ref/Quantity]):

Probability[x<Quantity[y,"Pounds"]\[Conditioned]x>Quantity[3,"Grams"],{x\[Distributed]QuantityDistribution[ExponentialDistribution[3],"Grams"],y\[Distributed]GammaDistribution[2,3]}]

OpenersExampleSubsection2(Spacer1)Parametric Distributions  (4)

Compute probabilities for univariate continuous distributions:

Probability[x<1/2,x\[Distributed]BetaDistribution[α,β]]

Probability[3<x^2<7,x\[Distributed]UniformDistribution[{-2,11}]]

Probability[(x-3)^2<5,x\[Distributed]NormalDistribution[0,1]]

Probability[E^(-x)>3x,x\[Distributed]ChiSquareDistribution[ν]]

Compute probabilities for univariate discrete distributions:

Probability[2<x<9,x\[Distributed]BinomialDistribution[10,p]]

Probability[x>10,x\[Distributed]DiscreteUniformDistribution[{min,max}]]

Probability[x^3<12,x\[Distributed]ZipfDistribution[ρ]]

Probability[E^(2x)>3,x\[Distributed]PoissonDistribution[λ]]

Probabilities for multivariate continuous distributions:

Probability[x+y^2<7,{x\[Distributed]UniformDistribution[{0,1}],y\[Distributed]LaplaceDistribution[0,1]}]

Probability[x+3y<1,{x\[Distributed]NormalDistribution[0,1],y\[Distributed]ExponentialDistribution[m]}]

Probability[1/3<x<1/2&&1/7<y<11/13,{x,y,z}\[Distributed]DirichletDistribution[{2,3,4,7}]]

Probabilities for multivariate discrete distributions:

Probability[x+y^2<6,{x,y}\[Distributed]ProductDistribution[DiscreteUniformDistribution[{2,5}],BernoulliDistribution[p]]]

Probability[x+y<4,{x\[Distributed]ZipfDistribution[3],y\[Distributed]PoissonDistribution[λ]}]

Probability[2<x<8&&5<y<8&&z<3,{x,y,z}\[Distributed]DiscreteUniformDistribution[{{2,12},{4,11},{-2,7}}]]

OpenersExampleSubsection3(Spacer1)Nonparametric Distributions  (4)

Compute probabilities using a univariate (RefLink[EmpiricalDistribution, paclet:ref/EmpiricalDistribution]):

𝒟=EmpiricalDistribution[RandomVariate[NormalDistribution[],100]];

Probability[(x^2)>1,x\[Distributed]𝒟]

Using a multivariate empirical distribution:

𝒟=EmpiricalDistribution[RandomVariate[BinormalDistribution[1/3],100]];

Probability[x+(y^2)>1,{x,y}\[Distributed]𝒟]

Using a univariate (RefLink[HistogramDistribution, paclet:ref/HistogramDistribution]):

𝒟=HistogramDistribution[RandomVariate[ExponentialDistribution[2],100]];

Probability[x^2+x>1,x\[Distributed]𝒟]

A multivariate histogram distribution:

𝒟=HistogramDistribution[RandomVariate[BinormalDistribution[1/3],10^3],4];

Probability[x+y>1,{x,y}\[Distributed]𝒟]

Using a univariate (RefLink[KernelMixtureDistribution, paclet:ref/KernelMixtureDistribution]):

𝒟=KernelMixtureDistribution[RandomVariate[NormalDistribution[],10]];

Probability[x^2+2x>3,x\[Distributed]𝒟]

Using censored data with (RefLink[SurvivalDistribution, paclet:ref/SurvivalDistribution]):

eventTimes={10,7,23,22,6,25,20,19,6,17,6,13};

censorIndicators={0,0,0,0,0,1,1,1,0,1,0,0};

𝒟=SurvivalDistribution[EventData[eventTimes,censorIndicators]];

Probability[x<25,x\[Distributed]𝒟]

OpenersExampleSubsection4(Spacer1)Derived Distributions  (9)

Compute the probability using a (RefLink[TransformedDistribution, paclet:ref/TransformedDistribution]):

Probability[x<2,x\[Distributed]TransformedDistribution[y^2,y\[Distributed]NormalDistribution[0,1]]]

An equivalent way of formulating the same probability:

Probability[y^2<2,y\[Distributed]NormalDistribution[0,1]]

FullSimplify[%%-%]

Find the probability using a (RefLink[ProductDistribution, paclet:ref/ProductDistribution]):

Probability[x+y<4,{x,y}\[Distributed]ProductDistribution[ExponentialDistribution[2],TriangularDistribution[{3,7}]]]

An equivalent formulation for the same probability:

Probability[x+y<4,{x\[Distributed]ExponentialDistribution[2],y\[Distributed]TriangularDistribution[{3,7}]}]

Using a component mixture of normal distributions:

Probability[E^x<2,x\[Distributed]MixtureDistribution[{1,2},{NormalDistribution[2,3],NormalDistribution[4,5]}]]

Parameter mixture of exponential distributions:

Probability[1/3 < x < 1, x \[Distributed] ParameterMixtureDistribution[ExponentialDistribution[λ], λ \[Distributed] UniformDistribution[{1, 2}]]]

Truncated Dirichlet distribution:

Probability[2/3<x^2+y<4/5,{x,y}\[Distributed]TruncatedDistribution[{{1/3,1/2},{1/6,5/6}},DirichletDistribution[{2,4,7}]]]

Censored triangular distribution:

Probability[30<x^2<200,x\[Distributed]CensoredDistribution[{5,30},TriangularDistribution[{1,50}]]]

Marginal distribution:

Probability[(x^2)+13 x<6,x\[Distributed]MarginalDistribution[DirichletDistribution[{1,2,3}],1]]

Copula distribution:

Probability[x+y<1/3, {x,y}\[Distributed]CopulaDistribution[{"AMH",1/5}, {UniformDistribution[{0,1}], UniformDistribution[{0,1}]}]]

Formula distribution:

Probability[E^x<2,x\[Distributed]ProbabilityDistribution[3/4(x^2+2x),{x,0,1}]]

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (3)

Compute a probability for a mixture of discrete and continuous distributions:

Probability[1<x^2<21,x\[Distributed]MixtureDistribution[{1,2},{ExponentialDistribution[1/7],PoissonDistribution[2/7]}]]

Specify independent distributions using && rather than a list notation:

Probability[1<x+y<8,x\[Distributed]ExponentialDistribution[3]&&y\[Distributed]NormalDistribution[]]

Use a pure function to compute a probability for a list of values:

r=RandomVariate[NormalDistribution[],1000];

Probability[#^2+3#<11&,r]

OpenersExampleSection3(Spacer1)Options  (5)

OpenersExampleSubsection5(Spacer1)Assumptions  (1)

With no (RefLink[Assumptions, paclet:ref/Assumptions]), conditions are generated:

Probability[x<a,x\[Distributed]UniformDistribution[{m,8}]]

With (RefLink[Assumptions, paclet:ref/Assumptions]), a result valid under the given assumptions is returned:

Probability[x<a,x\[Distributed]UniformDistribution[{m,8}], Assumptions-> 5<a<7&&m<a]

Assuming[5<a<7&&m<a,Probability[x<a,x\[Distributed]UniformDistribution[{m,8}]]]

OpenersExampleSubsection6(Spacer1)Method  (4)

Compute a probability using the default method:

Probability[3<x<8,x\[Distributed]ExponentialDistribution[2]]

The computed probability is given by a difference of two (RefLink[CDF, paclet:ref/CDF]) evaluations:

Probability[3<x<8,x\[Distributed]ExponentialDistribution[2],Method->"CDF"]

CDF[ExponentialDistribution[2],8]-CDF[ExponentialDistribution[2],3]//Together

Here, the CDF method fails because the predicate is transcendental:

Probability[E^(-x)+x<3,x\[Distributed]NormalDistribution[0,1],Method->"CDF"]

The probability can be computed using the PDF and symbolic integration:

Probability[E^(-x)+x<3,x\[Distributed]NormalDistribution[0,1],Method->"PDF"]

Probability[E^(-x)+x<3,x\[Distributed]NormalDistribution[0,1]]

Compute the probability of an event for (RefLink[TukeyLambdaDistribution, paclet:ref/TukeyLambdaDistribution]):

Probability[E^(-x)<1/2,Distributed[x,TukeyLambdaDistribution[1/3]]]

This uses the (RefLink[Quantile, paclet:ref/Quantile]) since the PDF of the distribution is not available in closed form:

Probability[E^(-x)<1/2,Distributed[x,TukeyLambdaDistribution[1/3]],Method->"Quantile"]

Integrate[Boole[(E^(-x)/.{x->Quantile[TukeyLambdaDistribution[1/3],p]})<1/2],{p,0,1}]

Compute the probability of an event for a continuous distribution:

Probability[E^x<2,x\[Distributed]NormalDistribution[]]

This example uses (RefLink[Integrate, paclet:ref/Integrate]):

Probability[E^x<2,x\[Distributed]NormalDistribution[],Method->"Trace"]

Use (RefLink[Activate, paclet:ref/Activate]) to evaluate the result:

Activate[%]

OpenersExampleSection4(Spacer1)Applications  (50)

OpenersExampleSubsection7(Spacer1)Random Experiments  (8)

A coin-tossing experiment consists of tossing a fair coin repeatedly until a head results. Simulate the process:

RandomVariate[GeometricDistribution[1/2],10]

ListPlot[RandomVariate[GeometricDistribution[1/2],100],Filling->Axis]

Compute the probability that at least 5 coin tosses will be necessary:

Probability[x≥5,x\[Distributed]GeometricDistribution[1/2]]

Compute the expected number of coin tosses:

Mean[GeometricDistribution[1/2]]

The number of heads in n flips with a fair coin can be modeled with (RefLink[BinomialDistribution, paclet:ref/BinomialDistribution]):

heads[n_]:=BinomialDistribution[n,1/2]

Show the distribution of heads for 100 coin flips:

DiscretePlot[PDF[heads[100],k],{k,0,100},PlotRange->All]

Compute the probability that there are between 60 and 80 heads in 100 coin flips:

Probability[60≤x≤80,x\[Distributed]heads[100]]

N[%]

Now, suppose that for an unfair coin the probability of heads is 0.6:

uheads[n_]:=BinomialDistribution[n,0.6];

The distribution and the corresponding probabilities have changed:

DiscretePlot[PDF[uheads[100],k],{k,0,100},PlotRange->All]

Probability[60≤x≤80,x\[Distributed]uheads[100]]

The number of tails before getting 4 heads with a fair coin:

heads4=NegativeBinomialDistribution[4,1/2];

Plot the distribution of tail counts:

DiscretePlot[PDF[heads4,k],{k,0,10}]

Compute the probability of getting at least 6 tails before getting 4 heads:

Probability[tails≥6,tails\[Distributed]heads4]

N[%]

Compute the expected number of tails before getting 4 heads:

Mean[heads4]

Find the probability that a randomly chosen point is the left part of the interval:

Probability[x<Mean[UniformDistribution[{min,max}]],x\[Distributed]UniformDistribution[{min,max}]]//Simplify

A fair six-sided die can be modeled using a (RefLink[DiscreteUniformDistribution, paclet:ref/DiscreteUniformDistribution]):

dice=DiscreteUniformDistribution[{1,6}];

Generate 10 throws of a die:

RandomVariate[dice,10]

Compute the probability that the sum of three dice values is less than 6:

Probability[Sum[x[i],{i,3}]≤6,{x[1]\[Distributed]dice,x[2]\[Distributed]dice,x[3]\[Distributed]dice}]

N[%]

Verify by generating random dice throws, in this case (10^5) times three dice throws:

Count[RandomVariate[dice,{10^5,3}],_?(Total[#]≤6&)]/10^5

N[%]

Verify by explicitly enumerating all possible dice outcomes:

Select[Tuples[Range[6],3],Total[#]≤6&]

Length[%]/6^3

Suppose an urn has 100 elements, of which 40 are special:

urn[n_]=HypergeometricDistribution[n,40,100];

The probability distribution that there are 20 special elements in a draw of 50 elements:

DiscretePlot[PDF[urn[50],k],{k,0,50},PlotRange->All]

Compute the probability that there are more than 25 special elements in a draw of 50 elements:

Probability[X>25,X\[Distributed]urn[50]]

N[%]

Compute the expected number of special elements in a draw of 50 elements:

Mean[urn[50]]

Probability of finding a prime number of the form 4 n+1 among the first 10000 primes:

Probability[Mod[#,4]==1&,Table[Prime[k],{k,10000}]]//N

Probability of finding a prime number of the form i+7 n among the first 100000 primes:

Table[Probability[Mod[#,7]==i&,Table[Prime[k],{k,100000}]]//N,{i,6}]

Probability that a random integer between 1 and 9999 will have digits that sum to 12:

Probability[x==12,x\[Distributed]Total[IntegerDigits[Range[9999]],{2}]]

OpenersExampleSubsection8(Spacer1)Sports and Games  (4)

Gary Kasparov, chess champion, plays in a tournament simultaneously against 100 amateurs. It has been estimated that he loses about 1% of such games. Find the probability of his losing 0, 2, 5, and 10 games:

Table[Probability[x==k,x\[Distributed]BinomialDistribution[100,0.01]],{k,{0,2,5,10}}]

Use a Poisson approximation to compute the same probabilities:

Table[Probability[x==k,x\[Distributed]PoissonDistribution[100 0.01]],{k,{0,2,5,10}}]

Perform the same computation when he is playing 5 games, but with stronger opposition so that his loss probability is 10% instead:

Table[Probability[x==k,x\[Distributed]BinomialDistribution[5,0.10]],{k,{0,2,5,10}}]

In this case the Poisson approximation is less accurate:

Table[Probability[x==k,x\[Distributed]PoissonDistribution[5 0.1]],{k,{0,2,5,10}}]

A basketball player has a free-throw percentage of 0.75. Simulate 10 free shots:

RandomVariate[BernoulliDistribution[0.75],10]/.{0->"Miss",1->"Hit"}

Find the probability that the player hits 2 out of 3 free shots in a game:

Probability[x==2,x\[Distributed]BinomialDistribution[3,0.75]]

In the game of craps [(WebLink[MathWorld, http://mathworld.wolfram.com/Craps.html])], two dice are thrown:

Craps=ProductDistribution[{DiscreteUniformDistribution[{1,6}],2}];

The resulting PDF can be tabulated as:

crapsProb=Table[PDF[Craps,{d1,d2}],{d1,6},{d2,6}];

TableForm[crapsProb,TableHeadings->{Range[6],Range[6]}]

Find the probability of getting "snake eyes" [(WebLink[MathWorld, http://mathworld.wolfram.com/SnakeEyes.html])]:

Probability[D1+D2==2,{D1,D2}\[Distributed]Craps]

Or "boxcars" [(WebLink[MathWorld, http://mathworld.wolfram.com/Boxcars.html])]:

Probability[D1+D2==12,{D1,D2}\[Distributed]Craps]

Or "eighter from Decatur" [(WebLink[MathWorld, http://mathworld.wolfram.com/EighterfromDecatur.html])]:

Probability[D1+D2==8,{D1,D2}\[Distributed]Craps]

Or "little Joe" [(WebLink[MathWorld, http://mathworld.wolfram.com/LittleJoe.html])]:

Probability[D1+D2==4,{D1,D2}\[Distributed]Craps]

The full list of probabilities:

Table[Probability[D1+D2==k,{D1,D2}\[Distributed]Craps],{k,12}]

Find the probability of losing in one throw or getting craps, i.e. any of the sums 2, 3, or 12:

Probability[D1+D2==2∨D1+D2==3∨D1+D2==12,{D1,D2}\[Distributed]Craps]

Find the probability of winning in one throw, i.e. getting the sums 7 or 11:

Probability[D1+D2==7∨D1+D2==11,{D1,D2}\[Distributed]Craps]

Find the distribution of the number of spades in a five-card poker hand:

PDF[HypergeometricDistribution[5,13,52],k]

DiscretePlot[%,{k,0,5},FillingStyle->Thick]

Find the probability that there are at least 2 spades in the poker hand:

Probability[X≥2,X\[Distributed]HypergeometricDistribution[5,13,52]]

N[%]

OpenersExampleSubsection9(Spacer1)Actuarial Science   (5)

An actuary has discovered that policy holders are three times as likely to file two claims as to file four claims. Assuming the number of claims filed follows a Poisson distribution, find the variance of the number of claims filed:

prob2=Probability[x==2,x\[Distributed]PoissonDistribution[m]];
prob4=Probability[x==4,x\[Distributed]PoissonDistribution[m]];

Solve[prob2==3prob4&&m>0,m]

Variance[PoissonDistribution[m/.First[%]]]

A group insurance policy covers the medical claims of the employees of a small company. The value, v, of the claims made in one year is described by v=100,000y, where y is a random variable with density function proportional to (((1-y))^4) for 0<y<1. Find the conditional probability that v exceeds 40000, given that y exceeds 10000:

k= 1/Integrate[(1-y)^4,{y,0,1}]

dist=TransformedDistribution[100000x, x\[Distributed]ProbabilityDistribution[ k(1-y)^4,{y,0,1}]];

Probability[m>40000\[Conditioned]m>10000,m\[Distributed]dist]//N[#,3]&

Two insurers provide bids on an insurance policy to a large company. The bids must be between 2000 and 2200. The company decides to accept the lower bid if the two bids differ by 20 or more. Otherwise, the company will consider the two bids further. Assume that the two bids are independent and are both uniformly distributed on the interval from 2000 to 2200. Determine the probability that the company considers the two bids further:

Probability[Abs[x-y]<20,{x,y}\[Distributed]ProductDistribution[{UniformDistribution[{2000,2200}],2}]]

Claims filed under auto insurance policies follow a normal distribution with mean $19400 and standard deviation $5000. Find the probability that the average of 25 randomly selected claims exceeds $20000:

sd=(QuantityPrefix[5000, "$" , US dollars, "USDollars"])/Sqrt[25];

Probability[x>(QuantityPrefix[20000, "$" , US dollars, "USDollars"]),x\[Distributed]NormalDistribution[(QuantityPrefix[19400, "$" , US dollars, "USDollars"]),sd]]//N

The waiting time for the first claim from a good driver and the waiting time for the first claim from a bad driver are independent and follow exponential distributions with means 6 years and 3 years, respectively. Compute the probability that the first claim from a good driver will be filed within 3 years and the first claim from a bad driver will be filed within 2 years:

claim𝒟=ProductDistribution[ExponentialDistribution[1/Quantity[6,"Years"]],ExponentialDistribution[1/Quantity[3,"Years"]]]

Probability[x≤Quantity[3,"Years"]&&y≤Quantity[2,"Years"],{x,y}\[Distributed]claim𝒟]

N[%]

OpenersExampleSubsection10(Spacer1)Weather  (3)

The expected number of raindrops falling into a bucket in a 5-second interval is 20. Simulate the raindrop count for each 5-second interval:

RandomVariate[PoissonDistribution[20],20]

ListPlot[%,Filling->Axis]

Find the probability that more than 20 raindrops fall into the bucket in 5 seconds:

Probability[x>20,x\[Distributed]PoissonDistribution[20.]]

Logistic distribution can be used to approximate wind speeds:

wind=WeatherData["Chicago", "WindSpeed", {{2006, 1, 1}, {2009, 12,31}, "Day"}];

Find the estimated distribution:

windEstimate=EstimatedDistribution[wind,LogisticDistribution[μ,β]]

Compare the PDF to the histogram of the wind data:

Show[Histogram[wind,Automatic,"PDF",AxesLabel->Automatic],Plot[PDF[windEstimate,Quantity[x,"km/h"]],{x,0,40},PlotStyle->Thick]]

Find the probability of a day with wind speed greater than 30 km/h:

Probability[x>Quantity[30,"km/h"],x\[Distributed]windEstimate]

Find mean wind speed:

Mean[windEstimate]

Cloud duration approximately follows a beta distribution with parameters 0.3 and 0.4 for a particular location. Find the probability that cloud duration will be longer than half a day:

Probability[x>0.5,x\[Distributed]BetaDistribution[0.3,0.4]]

Simulate the fraction of the day that is cloudy over a period of one month:

month=RandomVariate[BetaDistribution[0.3,0.4],30];

ListPlot[month,Filling->Axis]

Find the average cloudiness duration for a day:

Mean[BetaDistribution[0.3,0.4]]

Find the probability of having exactly 20 days in a month with cloud duration less than 10%:

p=Probability[x<0.1,x\[Distributed]BetaDistribution[0.3,0.4]];

Probability[k==20,k\[Distributed]BinomialDistribution[30,p]]

Find the probability of at least 20 days in a month with cloud duration less than 10%:

Probability[k≥20,k\[Distributed]BinomialDistribution[30,p]]

OpenersExampleSubsection11(Spacer1)Traffic  (4)

A switchboard receives on average 100 calls per minute. Find the switchboard capacity so that it gets saturated less than once in every 60 minutes:

satprob=Probability[x>Quantity[c,"Minutes"],x\[Distributed]QuantityDistribution[PoissonDistribution[100],"Minutes"],Assumptions->c∈Integers&&c>0]

Show[Plot[1/60,{x,110,140},PlotStyle->Orange],DiscretePlot[satprob,{c,110,140},PlotRange->All]]

Find the minimum capacity that satisfies the constraint:

Minimize[{c,satprob≤1/60&&110<c<140},c,Integers]

Two trains arrive at a station independently and stay for 10 minutes. If the arrival times are uniformly distributed, find the probability the two trains will meet at the station within one hour:

Probability[Abs[x-y]<10,{x,y}\[Distributed]UniformDistribution[{{0,60},{0,60}}]]

The region where the two trains meet:

RegionPlot[Abs[x-y]<10,{x,0,60},{y,0,60},FrameLabel->{"train 1","train 2"}]

A person is standing by a road counting cars until he sees a black one, at which point he restarts the count. Simulate the counting process, assuming that 10% of the cars are black:

RandomVariate[GeometricDistribution[0.1],20]

ListPlot[%,Filling->Axis]

Find the expected number of cars to come by before the count starts over:

Mean[GeometricDistribution[0.1]]

Find the probability of counting 10 or more cars before a black one:

Probability[x≥10,x\[Distributed]GeometricDistribution[0.1]]

Assume that the delay caused by a traffic signal is exponentially distributed with an average delay of 0.5 minutes. A driver has to drive a route that passes through seven unsynchronized traffic signals. Find the distribution for the delay passing all signals:

{sol}=Solve[Mean[ExponentialDistribution[λ]]==Quantity[1/2,"Minutes"],λ]

Hence the distribution for the sum of 7 independent exponential variables:

trafficDelayDistribution=ErlangDistribution[7,λ]/.sol

Find the probability that traffic signals cause a delay greater than 5 minutes:

Probability[d>Quantity[5,"Minutes"],d\[Distributed]trafficDelayDistribution]

N[%]

OpenersExampleSubsection12(Spacer1)Reliability  (5)

A battery has a lifetime that is approximately normally distributed with a mean of 1000 hours and a standard deviation of 50 hours. Find the fraction with a lifetime between 800 and 1000 hours:

Probability[Quantity[800,"Hours"]<x<Quantity[1000,"Hours"],x\[Distributed]NormalDistribution[Quantity[1000,"Hours"],Quantity[50,"Hours"]]]

Out of 100 batteries, compute how many have a lifetime between 800 and 1000 hours:

100 %

N[%]

Suppose the lifetime of an appliance has an exponential distribution with an average lifetime of 10 years. Find the appliance lifetime distribution:

{sol}=Solve[Mean[ExponentialDistribution[λ]]==Quantity[10,"Years"],λ]

applianceLifetimeDistribution=ExponentialDistribution[λ]/.sol

Find the probability that a used appliance with (Subscript[t, 0]) years of use will not fail in the next 5 years:

Probability[t>Quantity[t0,"Years"]+Quantity[5.,"Years"]\[Conditioned]t>Quantity[t0,"Years"],t\[Distributed]applianceLifetimeDistribution,Assumptions->t0>0]

Using the memoryless property of (RefLink[ExponentialDistribution, paclet:ref/ExponentialDistribution]):

Probability[t>Quantity[5.,"Years"],t\[Distributed]applianceLifetimeDistribution]

A system uses triple redundancy with three microprocessors and is designed to operate as long as one processor is still functional. The probability that a microprocessor is still functional after t seconds is p=exp(-λ t). Find the probability that the system is still operating after t seconds:

Probability[x≥1,x\[Distributed]BinomialDistribution[3,Exp[-λ t]]]

With mean time to failure for each processor λ=(10^(-8))(s^(-1)), find out when the system functions with a probability of less than 99%:

Reduce[(%/.λ->(10^(-8)))≤0.99,t,Reals]//Quiet

Expressed in years:

Last[%]/(3600 365)

A budget-priced lighter has 0.90 probability of lighting on any given attempt. Simulate the lighting process; the result indicates the number of failures before successful lighting:

BarChart[RandomVariate[GeometricDistribution[0.90],20]]

Find the probability that the lighter lights in 3 trials or less:

Probability[x≤3,x\[Distributed]GeometricDistribution[0.90]]

A system is composed of 4 independent components, each with lifespan exponentially distributed with parameter (10^(-3)). Find the probability that no component fails before 500 hours:

Probability[t1>(Quantity[500, "h", hours, "Hours"])&&t2>(Quantity[500, "h", hours, "Hours"])&&t3>(Quantity[500, "h", hours, "Hours"])&&t4>(Quantity[500, "h", hours, "Hours"]),{t1,t2,t3,t4}\[Distributed]ProductDistribution[{ExponentialDistribution[1/(Quantity[1000, "h", hours, "Hours"])],4}]]

N[%]

Directly use (RefLink[SurvivalFunction, paclet:ref/SurvivalFunction]):

SurvivalFunction[ExponentialDistribution[1/(Quantity[1000, "h", hours, "Hours"])],(Quantity[500, "h", hours, "Hours"])]^4

Find the probability that exactly one component will fail in the first 1200 hours:

Binomial[4,1]Probability[t1≤(Quantity[1200, "h", hours, "Hours"])&&t2>(Quantity[1200, "h", hours, "Hours"])&&t3>(Quantity[1200, "h", hours, "Hours"])&&t4>(Quantity[1200, "h", hours, "Hours"]),{t1,t2,t3,t4}\[Distributed]ProductDistribution[{ExponentialDistribution[1/(Quantity[1000, "h", hours, "Hours"])],4}]]

Directly use (RefLink[CDF, paclet:ref/CDF]) and (RefLink[SurvivalFunction, paclet:ref/SurvivalFunction]):

Binomial[4,1] CDF[ExponentialDistribution[1/(Quantity[1000, "h", hours, "Hours"])],(Quantity[1200, "h", hours, "Hours"])] SurvivalFunction[ExponentialDistribution[1/(Quantity[1000, "h", hours, "Hours"])],(Quantity[1200, "h", hours, "Hours"])]^3

N[%]

By using (RefLink[BooleanCountingFunction, paclet:ref/BooleanCountingFunction]), you can also define the logical condition:

ExactlyK[k_,v_]:=BooleanCountingFunction[{k},Length[v]]@@v

ExactlyK[1,{a,b,c,d}]//BooleanConvert

Probability[ExactlyK[1,{t1≤(Quantity[1200, "h", hours, "Hours"]),t2≤(Quantity[1200, "h", hours, "Hours"]),t3≤(Quantity[1200, "h", hours, "Hours"]),t4≤(Quantity[1200, "h", hours, "Hours"])}],{t1,t2,t3,t4}\[Distributed]ProductDistribution[{ExponentialDistribution[1/(Quantity[1000, "h", hours, "Hours"])],4}]]

N[%]

OpenersExampleSubsection13(Spacer1)Communication  (4)

A packet consisting of a string of n symbols is transmitted over a noisy channel. Each symbol has probability (10^(-4)) of incorrect transmission. Find n such that the probability of incorrect packet transmission is less than (10^(-3)):

Probability[x≥1,x\[Distributed]BinomialDistribution[n,(10^(-4))]]

Reduce[%≤(10^(-3)),n,Reals]

N[%]

Compute the same limit using a Poisson approximation:

Probability[x≥1,x\[Distributed]PoissonDistribution[n (10^(-4))]]

Reduce[%≤(10^(-3)),n,Reals]

N[%]

Assume that the duration of telephone calls is exponentially distributed. The average length of a telephone call is 3.7 minutes. Find the probability that 9 consecutive phone calls will be longer than 25 minutes:

{sol}=NSolve[Mean[ExponentialDistribution[λ]]==Quantity[3.7,"Minutes"],λ]

Summing 9 independent phone call durations:

phoneDurationDistribution=(ErlangDistribution[9,λ]/.sol)

The probability that they last longer than 25 minutes:

Probability[d>Quantity[25,"Minutes"],d\[Distributed]phoneDurationDistribution]

Waiting times at a receiver for signals coming from four independent transmitters are exponentially distributed with parameters (Subscript[λ, 1]), (Subscript[λ, 2]), (Subscript[λ, 3]), and (Subscript[λ, 4]), respectively. Find the probability that the signal from the third transmitter arrives first to the receiver:

Probability[Min[u,v,w,z]==w,{u\[Distributed]ExponentialDistribution[λ1],v\[Distributed]ExponentialDistribution[λ2],w\[Distributed]ExponentialDistribution[λ3],z\[Distributed]ExponentialDistribution[λ4]}]

Find the distribution of the waiting time for any signal at the receiver:

dist=TransformedDistribution[Min[u,v,w,z],{u\[Distributed]ExponentialDistribution[λ1],v\[Distributed]ExponentialDistribution[λ2],w\[Distributed]ExponentialDistribution[λ3],z\[Distributed]ExponentialDistribution[λ4]}]

Find the average waiting time for any signal at the receiver:

Mean[dist]

Simulate the waiting time between signals arriving at the receiver for (Subscript[λ, 1])=1, (Subscript[λ, 2])=0.5`, (Subscript[λ, 3])=0.7`, and (Subscript[λ, 4])=0.3`:

Block[{λ1=1,λ2=0.5,λ3=0.7,λ4=0.3},ListPlot[{RandomVariate[dist,100],{{0,Mean[dist]},{100,Mean[dist]}}},Joined->{False,True}]]

Assume that the time delay in a logic element is exponentially distributed and that the average delay is (10^(-9)) seconds. The longest sequence of logic elements in a combinational logic network is six. Find the probability that delay through all six elements is longer than 8.5×(10^(-9)) seconds:

Mean[ExponentialDistribution[λ]]==Quantity[(10^(-9)),"Seconds"]

NSolve[%,λ]

Summing 6 independent delay distributions:

logicDelayDistribution=(ErlangDistribution[6,λ]/.First[%])

The probability that the delay is greater than 8.5×(10^(-9)):

Probability[d>Quantity[8.5 (10^(-9)),"Seconds"],d\[Distributed]logicDelayDistribution]

OpenersExampleSubsection14(Spacer1)Quality  (4)

A student will take a test repeatedly until passing it, each time succeeding with probability p. Find the probability that the student succeeds in k attempts or fewer:

prob1=Probability[x≤k,x\[Distributed]GeometricDistribution[p],Assumptions->k∈Integers&&k≥0]

Block[{p=1/3},DiscretePlot[prob1,{k,10},AxesOrigin->{1,0}]]

Given that the student passes the test in n attempts or fewer, find the PDF:

prob2=Probability[x==k\[Conditioned]x≤n,x\[Distributed]GeometricDistribution[p],Assumptions->{k,n}∈Integers&&n>0]

Block[{p=1/3,n=3},DiscretePlot[prob2,{k,10},AxesOrigin->{1,0}]]

Assume the waiting time a customer spends in a restaurant is exponentially distributed with an average wait time of 5 minutes. Find the probability that the customer will have to wait more than 10 minutes:

Probability[t>Quantity[10.,"Minutes"],t\[Distributed]ExponentialDistribution[1/Quantity[5,"Minutes"]]]

Find the probability that the customer will have to wait an additional 10 minutes, given that he or she has already been waiting for at least 10 minutes (the past does not matter):

Probability[t>Quantity[10.+10,"Minutes"]\[Conditioned]t>Quantity[10,"Minutes"],t\[Distributed]ExponentialDistribution[1/Quantity[5,"Minutes"]]]

A company manufactures nails with length normally distributed, mean 0.497 inches, and standard deviation 0.002 inches. Find the fraction that satisfies the specification of length equal to 0.5 inches plus/minus 0.004 inches:

𝒟=NormalDistribution[Quantity[.497,"Inches"],Quantity[.002,"Inches"]]

Probability[Quantity[ .5-.004,"in"]<x<Quantity[.5+.004,"in"],x\[Distributed] 𝒟]

Direct computation with (RefLink[CDF, paclet:ref/CDF]):

CDF[ 𝒟,Quantity[.5+.004,"in"]]-CDF[ 𝒟,Quantity[.5-.004,"in"]]

Suppose there are 5 defective items in a batch of 10 items, and 6 items are selected for testing. Simulate the process of testing when the number of defective items found is counted:

RandomVariate[HypergeometricDistribution[6,5,10],20]

ListPlot[%,Filling->Axis]

Find the probability that there are 2 defective items in the sample:

Probability[X==2,X\[Distributed]HypergeometricDistribution[6,5,10]]

N[%]

OpenersExampleSubsection15(Spacer1)Probability Visualizations  (3)

Compute and illustrate the continuous probability P((1/2)<x≤1):

prob=Probability[1/2<x≤1,x\[Distributed]NormalDistribution[0,1]]

Plot a larger part of the PDF as well as a highlighted probability region:

{p1,p2}={Plot[PDF[NormalDistribution[0,1],x],{x,-2,2}],Plot[PDF[NormalDistribution[0,1],x],{x,1/2,1},AxesOrigin->{0,0},Filling->Axis]}

Show them all together:

Show[p1,p2,PlotLabel->Style[Row[{P[1/2≤x≤1],prob},"="],Small]]

Compute and illustrate the discrete probability P(3≤x≤7):

prob=Probability[3≤x≤7,x\[Distributed]GeometricDistribution[1/10]]

Plot a larger region of the PDF as well as a highlighted probability region:

{p1,p2}={DiscretePlot[PDF[GeometricDistribution[1/10],k],{k,0,20},ExtentSize->0.5],
DiscretePlot[PDF[GeometricDistribution[1/10],k],{k,3,7},ExtentSize->0.5,PlotStyle->Orange,PlotRange->{0,0.10}]}

Show them all together:

Show[p1,p2,PlotLabel->Row[{P[3≤x≤7],prob},"="]]

Compute and illustrate the discrete probability P[2≤x≤5∧3≤y≤7]:

prob=Probability[2≤x≤5∧3≤y≤7,{x,y}\[Distributed]MultinomialDistribution[10,{1/3,2/3}]]

Plot a larger region of the PDF as well as a highlighted probability region:

{p1,p2}={DiscretePlot3D[PDF[MultinomialDistribution[10,{1/3,2/3}],{x,y}],{x,0,10},{y,0,10},ExtentSize->0.5],
DiscretePlot3D[PDF[MultinomialDistribution[10,{1/3,2/3}],{x,y}],{x,2,5},{y,3,7},ExtentSize->0.5,PlotStyle->Orange]}

Show them together:

Show[p1,p2,PlotLabel->Row[{Pr[2≤x≤5∧3≤y≤7],prob},"="]]

OpenersExampleSubsection16(Spacer1)Other Applications  (5)

A radioactive material on average emits 3.2 α-particles per second; show the distribution:

DiscretePlot[PDF[PoissonDistribution[3.2],k],{k,0,10}]

Compute the probability that more than 4 α-particles are emitted over the next second:

Probability[x>4,x\[Distributed]PoissonDistribution[3.2]]

Simulate a typical particle count per second over 10 minutes:

ListLinePlot[RandomVariate[PoissonDistribution[3.2],60 10]]

A drug has proven to be effective in 30% of cases. Find the probability it is effective in 3 of 4 patients:

Probability[x≥3,x\[Distributed]BinomialDistribution[4,0.3]]

Find the expected number of successes when applied to 500 cases:

Expectation[x,x\[Distributed]BinomialDistribution[500,0.3]]

Logistic distribution provides very good fit for fractional price changes from the previous closing price of stocks. Find the estimated distribution for the daily fractional price changes of Standard & Poor's 500 index from January 1, 2000, to January 1, 2009:

sp500=TimeSeriesMap[Normal[#,Quantity]&,FinancialData["SP500","FractionalChange",{{2000,1,1},{2009,1,1},"Day"}]]

edist=EstimatedDistribution[sp500,LogisticDistribution[μ,β]]

Compare the histogram of the data with the PDF of the estimated distribution:

h=Histogram[sp500,Automatic,"ProbabilityDensity"];

Show[h,Plot[PDF[edist,x],{x,-.1,.1},PlotStyle->Thick,PlotRange->All]]

Find the probability of the fractional price change being greater than 0.5%:

Probability[x>0.005,x\[Distributed]edist]

Find the mean fractional price change:

Mean[edist]

Simulate fractional price changes for 30 days:

ListPlot[RandomVariate[edist,30],Joined->True]

Show that using logistic distribution provides better fit than when using (RefLink[LogNormalDistribution, paclet:ref/LogNormalDistribution]):

LNestimate=EstimatedDistribution[1+sp500,LogNormalDistribution[μ,σ]]

Show[h,Plot[{PDF[edist,x],PDF[LNestimate,x+1]},{x,-0.1,0.1},PlotStyle->Thick]]

Compute p-values for a z-test with alternative hypothesis x<z:

Probability[x<z,x\[Distributed]NormalDistribution[]]

Alternative hypothesis x>z:

Probability[x>z,x\[Distributed]NormalDistribution[]]

Compute the probabilities of events in the complex plane:

Probability[Abs[x+I y]≤1,{x,y}\[Distributed]ProductDistribution[{UniformDistribution[],2}]]

Probability[x<Abs[x^2+I y]<5,{x,y}\[Distributed]ProductDistribution[{UniformDistribution[{-3,7}],2}]]//FullSimplify

N[%]

NProbability[x<Abs[x^2+I y]<5,{x,y}\[Distributed]ProductDistribution[{UniformDistribution[{-3,7}],2}]]

OpenersExampleSubsection17(Spacer1)Elections  (1)

Candidate A defeated candidate B in an election, securing the support of 60% of voters. Find the probability that candidate A will be strictly ahead of candidate B throughout the count:

Probability[And@@Thread[Accumulate[{x1,x2,x3,x4,x5}]>0],{x1,x2,x3,x4,x5}\[Distributed]Permutations[{1,1,1,-1,-1}]]

OpenersExampleSubsection18(Spacer1)Boy or Girl?  (1)

A family with two children is known to have a boy. Assuming boys and girls are equally likely among newborns, find the probability that the other child is a girl:

Probability[(fc==1||sc==1)\[Conditioned](fc==0||sc==0),{fc,sc}\[Distributed]ProductDistribution[BernoulliDistribution[1/2],BernoulliDistribution[1/2]]]

Assume a 52% chance of having a boy:

Probability[(fc==1||sc==1)\[Conditioned](fc==0||sc==0),{fc,sc}\[Distributed]ProductDistribution[BernoulliDistribution[0.52],BernoulliDistribution[0.52]]]

OpenersExampleSubsection19(Spacer1)Theoretical versus Sample Probabilities  (1)

Compute the probability of an event in a triangular distribution:

Probability[x^2<1,x\[Distributed]TriangularDistribution[{-3,3}]]//N

Compare the theoretical value with the value obtained by using a random sample:

r=RandomVariate[TriangularDistribution[{-3,3}],10^6];

Probability[x^2<1,x\[Distributed]r]//N

OpenersExampleSubsection20(Spacer1)Triangle Construction  (1)

Consider a stick of length 1. Pick two points uniformly at random on the stick, and break the stick at those points. Find the probability that the three segments obtained in this way form a triangle. Start with a predicate for a valid triangle:

triangleQ[x_,y_,z_]:=x≤y+z&&y≤z+x&&z≤x+y;

Break the stick uniformly and independently at two locations u1 and u2:

f=UniformDistribution[{{0,1},{0,1}}];

Compute the required probability:

Probability[triangleQ[Min[u1,u2],Abs[u2-u1],1-Max[u1,u2]],{u1,u2}\[Distributed]f]

OpenersExampleSubsection21(Spacer1)Regions  (1)

Find the probability over a (RefLink[Disk, paclet:ref/Disk]) for a (RefLink[DirichletDistribution, paclet:ref/DirichletDistribution]):

Probability[x>y&&{x,y}∈Disk[],{x,y}\[Distributed]DirichletDistribution[{1,2,3}]]

OpenersExampleSection5(Spacer1)Properties & Relations  (11)

The probability of an impossible event is 0:

Probability[x<3,x\[Distributed]UniformDistribution[{3,5}]]

The probability of a certain event is 1:

Probability[3<x<5,x\[Distributed]UniformDistribution[{3,5}]]

The probability of an arbitrary event must lie between 0 and 1:

Probability[1<x<4,x\[Distributed]UniformDistribution[{3,5}]]

A conditional probability is defined by a ratio of probabilities:

𝒟=PoissonDistribution[1];

a=x>5;b=x>1;

Probability[a\[Conditioned]b,x\[Distributed]𝒟]==((Probability[a∧b,x\[Distributed]𝒟])/(Probability[b,x\[Distributed]𝒟]))

The probability of the union of disjoint events is the sum of the individual probabilities:

𝒟=PoissonDistribution[3];

a=x>5;b=x<1;

Probability[a∨b,x\[Distributed]𝒟]==Probability[a,x\[Distributed]𝒟]+Probability[b,x\[Distributed]𝒟]

For non-disjoint events, one needs to subtract the probability of an intersection event:

a=x>5;b=6 <x<8;

Probability[a∨b,x\[Distributed]𝒟]==Probability[a,x\[Distributed]𝒟]+Probability[b,x\[Distributed]𝒟]-Probability[a∧b,x\[Distributed]𝒟]

For a distribution specified by a list, (RefLink[Probability, paclet:ref/Probability]) computes relative frequencies:

data={1,2,3,4,5,6,7,8,9,10,11};

Probability[3≤x≤7,x\[Distributed]data]

Length[Select[data,3≤#≤7&]]/Length[data]

The probability of an event in a continuous distribution is defined by an integral:

𝒟=NormalDistribution[];

Probability[E^x<3, x\[Distributed]𝒟]==(∫_(-∞)^∞)Boole[E^x<3]PDF[𝒟,x]\[DifferentialD]x

The probability of an event in a discrete distribution is defined by a sum:

𝒟=PoissonDistribution[1];

Probability[E^x<3, x\[Distributed]𝒟]==(∑_(x=-∞)^∞)Boole[E^x<3]PDF[𝒟,x]

The CDF of a distribution can be expressed in terms of (RefLink[Probability, paclet:ref/Probability]):

𝒟=ExponentialDistribution[2];

CDF[𝒟,3]==Probability[x≤3,x\[Distributed]𝒟]

The survival function for a distribution can be expressed in terms of (RefLink[Probability, paclet:ref/Probability]):

𝒟=GeometricDistribution[1/5];

SurvivalFunction[𝒟,3]==Probability[x>3,x\[Distributed]𝒟]

The hazard function for a distribution can be expressed in terms of (RefLink[Probability, paclet:ref/Probability]):

𝒟=PoissonDistribution[2];

HazardFunction[𝒟,3]==((Probability[x==3,x\[Distributed]𝒟])/(Probability[x>=3,x\[Distributed]𝒟]))//FullSimplify

Use (RefLink[NProbability, paclet:ref/NProbability]) to find the numerical value for the probability of an event:

dist=ExponentialDistribution[1];

{Probability[x≤2,x\[Distributed]dist],NProbability[x≤2,x\[Distributed]dist]}

N[%]

The probability of an event is equivalent to the (RefLink[Expectation, paclet:ref/Expectation]) of the (RefLink[Boole, paclet:ref/Boole]) of the event:

𝒟=ExponentialDistribution[2];

Probability[1<x<3,x\[Distributed]𝒟]==Expectation[Boole[1<x<3],x\[Distributed]𝒟]

OpenersExampleSection7(Spacer1)Neat Examples  (1)

Find the probability that a quadratic polynomial with random coefficients has real roots, assuming that the coefficients follow independent exponential distributions:

Probability[Discriminant[a x^2+b x+c,x]≥0,{a,b,c}\[Distributed]ProductDistribution[ExponentialDistribution[(Subscript[μ, 1])],ExponentialDistribution[(Subscript[μ, 2])],ExponentialDistribution[(Subscript[μ, 3])]]]

If the coefficients are equidistributed:

Probability[Discriminant[a x^2+b x+c,x]≥0,{a,b,c}\[Distributed]ProductDistribution[ExponentialDistribution[μ],ExponentialDistribution[μ],ExponentialDistribution[μ]]]

If the coefficients are uniformly distributed:

Probability[Discriminant[a x^2+b x+c,x]≥0,{a,b,c}\[Distributed]UniformDistribution[{{0,1},{0,1},{0,1}}]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[NProbability, paclet:ref/NProbability])  ▪  (RefLink[Distributed, paclet:ref/Distributed])  ▪  (RefLink[Conditioned, paclet:ref/Conditioned])  ▪  (RefLink[Expectation, paclet:ref/Expectation])  ▪  (RefLink[NExpectation, paclet:ref/NExpectation])  ▪  (RefLink[CDF, paclet:ref/CDF])  ▪  (RefLink[PDF, paclet:ref/PDF])  ▪  (RefLink[SurvivalFunction, paclet:ref/SurvivalFunction])  ▪  (RefLink[ProbabilityDistribution, paclet:ref/ProbabilityDistribution])  ▪  (RefLink[Sum, paclet:ref/Sum])  ▪  (RefLink[Integrate, paclet:ref/Integrate])  ▪  (RefLink[RegionPlot, paclet:ref/RegionPlot])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Probability & Statistics, paclet:guide/ProbabilityAndStatistics])}, {▪(RefLinkPlain[Random Processes, paclet:guide/RandomProcesses])}, {▪(RefLinkPlain[Random Variables, paclet:guide/RandomVariables])}, {▪(RefLinkPlain[Actuarial Computation, paclet:guide/ActuarialComputation])}, {▪(RefLinkPlain[Scientific Models, paclet:guide/ScientificModels])}, {▪(RefLinkPlain[Solvers over Regions, paclet:guide/GeometricSolvers])}, {▪(RefLinkPlain[Statistical Data Analysis, paclet:guide/Statistics])}, {▪(RefLinkPlain[Reliability, paclet:guide/Reliability])}, {▪(RefLinkPlain[Random Graphs, paclet:guide/RandomGraphs])}, {▪(RefLinkPlain[Descriptive Statistics, paclet:guide/DescriptiveStatistics])}, {▪(RefLinkPlain[Probability & Statistics with Quantities, paclet:guide/ProbabilityWithQuantities])}})}})