Probability
Probability[pred,xdist]
gives the probability for an event that satisfies the predicate pred under the assumption that x follows the probability distribution dist.
Probability[pred,xdata]
gives the probability for an event that satisfies the predicate pred under the assumption that x follows the probability distribution given by data.
Probability[pred,{x1,x2,…}dist]
gives the probability that an event satisfies pred under the assumption that {x1,x2,…} follows the multivariate distribution dist.
Probability[pred,{x1dist1,x2dist2,…}]
gives the probability that an event satisfies pred under the assumption that x1, x2, … are independent and follow the distributions dist1, dist2, ….
Probability[pred1pred2,…]
gives the conditional probability of pred1 given pred2.
Details and Options

- xdist can be entered as x
dist
dist or x∖[Distributed]dist.
- pred1pred2 can be entered as pred1
cond
pred2 or pred1∖[Conditioned]pred2.
- For a continuous distribution dist, the probability of pred is given by ∫Boole[pred]f[x]x 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 ∑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 Sum[Boole[pred],{x,data}]/Length[data].
- Univariate data is given as a list of values {v1,v2,…} and multivariate data is given as a list of vectors {{v11,…,v1m},{v21,…,v2m},…}.
- Probability[pred,{x1dist1,x2dist2}] corresponds to Expectation[Probability[pred,x2dist2],x1dist1] so that the last variable is summed or integrated first.
- N[Probability[…]] calls NProbability for probabilities that cannot be evaluated symbolically.
- The following options can be given:
-
Assumptions $Assumptions assumptions to make about parameters GenerateConditions False whether to generate conditions on parameters Method Automatic what method to use
Background & Context
- Probability[pred,x] represents the probability for an event that satisfies a predicate pred under the assumption that the chosen random variable x follows an indicated probability distribution (i.e. is a discrete or continuous distribution such as NormalDistribution, BinomialDistribution, ChiSquareDistribution, etc.) or is taken from a given dataset (i.e. defines a dataset), and where is a shorthand for Distributed. The output
of Probability is either a number
(where the probability of an impossible event is 0 while the probability for a certain event is 1) or a symbolic expression involving the input parameters.
- Probability also works with multivariate distributions; with nonparametric distributions such as EmpiricalDistribution, HistogramDistribution, and KernelMixtureDistribution; and with derived distributions such as TransformedDistribution and ProductDistribution. In addition, Probability may be applied to random processes, including those defined by ContinuousMarkovProcess, DiscreteMarkovProcess, WienerProcess, and PoissonProcess.
- The predicate pred may include both linear and nonlinear inequalities, as well as logical combinations of inequalities. Probability can compute conditional probabilities using a predicate of the form pred1pred2, where is a shorthand for Conditioned. A number of options may be passed to Probability, including Assumptions, GenerateConditions, and Method. The output provided by Probability is calculated using exact methods such as symbolic integration and summation. Corresponding results involving numerical methods can be obtained via NProbability.
- Several Wolfram Language functions, including PDF, CDF, and SurvivalFunction, return results that are equivalent to those obtainable using Probability with particular predicate structures. In addition, results obtained by Probability may be obtained by Expectation by pairing Expectation with a Boole construct. For example, Expectation[Boole[1<x<3],xNormalDistribution[]] is equivalent to Probability[1<x<3,xNormalDistribution[]].
- Probability can be used to exactly solve many problems in probability. For example, the probability that a toss of two dice will yield a sum of 3 or 4 is given by Probability[3≤x+y≤4,{x,y}DiscreteUniformDistribution[{{1,6},{1,6}}], while the chances that a triple
of uniformly distributed random variables satisfying
will yield a polynomial
with real roots can be computed using Probability[b2-4a c≥0,{a,b,c}UniformDistribution[Table[{0,1},{3}]]].
Examples
open allclose allSee Also
NProbability Distributed Conditioned Expectation NExpectation CDF PDF SurvivalFunction ProbabilityDistribution Sum Integrate RegionPlot