This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

NProbability

NProbability
gives the numerical probability for an event that satisfies the predicate pred under the assumption that x follows the probability distribution dist.
NProbability
gives the numerical probability that an event satisfies pred under the assumption that follows the multivariate distribution dist.
NProbability
gives the numerical probability that an event satisfies pred under the assumption that , , ... are independent and follow the distributions , , ....
NProbability
gives the numerical conditional probability of given .
  • can be entered as x Esc dist Esc dist or .
  • can be entered as Esc cond Esc or .
  • For a continuous distribution dist, the probability of pred is given by where 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 where is the probability density function of dist and the summation is taken over the domain of dist.
  • The following options can be given:
AccuracyGoaldigits of absolute accuracy sought
PrecisionGoalAutomaticdigits of precision sought
WorkingPrecisionMachinePrecisionthe precision used in internal computations
MethodAutomaticwhat method to use
Compute the probability of a simple event:
Compute the probability of a nonlinear and logical combination of inequalities:
Compute a conditional probability:
Compute the probability of a simple event:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=
 
Compute the probability of a nonlinear and logical combination of inequalities:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=
 
Compute a conditional probability:
In[1]:=
Click for copyable input
Out[1]=
Compute the probability of an event in a continuous univariate distribution:
Discrete univariate distribution:
Continuous multivariate distribution:
Discrete multivariate distribution:
Compute the probability using independently distributed random variables:
Find the conditional probability with general nonzero probability conditioning:
Discrete univariate distribution:
Multivariate continuous distribution:
Multivariate discrete distribution:
Compute the conditional probability with a zero-probability conditioning event:
Apply N to invoke NProbability if symbolic evaluation fails:
Use nonlinear predicates and arbitrary logical combinations:
Multivariate nonlinear predicates:
Visualize the region of the event:
Obtain results with different precisions:
Compute probabilities for univariate continuous distributions:
Compute probabilities for univariate discrete distributions:
Probabilities for multivariate continuous distributions:
Probabilities for multivariate discrete distributions:
Using a univariate HistogramDistribution:
A multivariate histogram distribution:
Using a univariate KernelMixtureDistribution:
Compute the probability using a TransformedDistribution:
An equivalent way of formulating the same probability:
Find the probability using a ProductDistribution:
An equivalent formulation for the same probability:
Using a component mixture of normal distributions:
Parameter mixture of exponential distributions:
Truncated Dirichlet distribution:
Censored triangular distribution:
Marginal distribution:
An equivalent way of formulating the same probability:
Copula distribution:
Formula distribution:
Compute a numerical probability for a mixture of discrete and continuous distributions:
Specify independent distributions using rather than a list notation:
Obtain a result with the default setting for accuracy:
Use AccuracyGoal to obtain the result with a different accuracy:
Here, the default number of recursive bisections gives a result with low accuracy:
Use the Method option to increase the number of recursive bisections for numerical integration:
Compare with the exact result from Probability:
Obtain a result with the default setting for precision:
Use PrecisionGoal to obtain the result with a different precision:
By default, NProbability uses machine precision:
Use WorkingPrecision to obtain results with higher precision:
A coin-tossing experiment consists of tossing a fair coin repeatedly until a head results. Simulate the process:
Compute the probability that at least 5 coin tosses will be necessary:
Compute the expected number of coin tosses:
The number of heads in flips with a fair coin can be modeled with BinomialDistribution:
Show the distribution of heads for 100 coin flips:
Compute the probability that there are between 60 and 80 heads in 100 coin flips:
Now, suppose that for an unfair coin the probability of heads is 0.6:
The distribution and the corresponding probabilities have changed:
A fair six-sided die can be modeled using a DiscreteUniformDistribution:
Generate 10 throws of a die:
Compute the probability that the sum of three dice values is less than 6:
Verify by generating random dice throws, in this case dice throws:
Verify by explicitly enumerating all possible dice outcomes:
The number of tails before getting 4 heads with a fair coin:
Plot the distribution of tail counts:
Compute the probability of getting at least 6 tails before getting 4 heads:
Compute the expected number of tails before getting 4 heads:
Suppose an urn has 100 elements, of which 40 are special:
The probability distribution that there are 20 special elements in a draw of 50 elements:
Compute the probability that there are more than 25 special elements in a draw of 50 elements:
Compute the expected number of special elements in a draw of 50 elements:
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:
Use a Poisson approximation to compute the same probabilities:
Perform the same computation when he is playing 5 games, but with stronger opposition so that his loss probability is 10% instead:
In this case the Poisson approximation is less accurate:
A basketball player has a free-throw percentage of 0.75. Simulate 10 free throws:
Find the probability that the player hits 2 out of 3 free throws in a game:
Find the distribution of the number of spades in a five-card poker hand:
Find the probability that there are at least 2 spades in the poker hand:
Logistic distribution can be used to approximate wind speeds:
Find the estimated distribution:
Compare the PDF to the histogram of the wind data:
Find the probability of a day with wind speed greater than 30 km/h:
Find the mean wind speed:
Simulate wind speeds for a month:
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:
Simulate the fraction of the day that is cloudy over a period of one month:
Find the average cloudiness duration for a day:
Find the probability of having exactly 20 days in a month with cloud duration less than 10%:
Find the probability of at least 20 days in a month with cloud duration less than 10%:
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:
Find the probability that more than 20 raindrops fall into the bucket in 5 seconds:
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:
The region where the two trains meet:
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:
Find the expected number of cars to come by before the count starts over:
Find the probability of counting 10 or more cars before a black one:
A group insurance policy covers the medical claims of the employees of a small company. The value of the claims made in one year is described by , where is a random variable with density function proportional to for . Find the conditional probability that exceeds 40000, given that exceeds 10000:
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:
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:
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:
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:
Out of 100 batteries, compute how many have a lifetime between 800 and 1000 hours:
A system is composed of 4 independent components, each with lifespan exponentially distributed with parameter . Find the probability that no component fails before 500 hours:
Directly use SurvivalFunction:
Find the probability that exactly one component will fail in the first 1200 hours:
Directly use CDF and SurvivalFunction:
By using BooleanCountingFunction you can also define the logical condition:
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:
Find the probability that the lighter lights in 3 trials or less:
A radioactive material on average emits 3.2 -particles per second; show the distribution:
Compute the probability that more than 4 -particles are emitted over the next second:
Simulate a typical particle count per second over 10 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:
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:
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):
A drug has proven to be effective in 30% of cases. Find the probability it is effective in 3 of 4 patients:
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:
Find the probability that there are 2 defective items in the sample:
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:
Summing 9 independent phone call durations:
The probability that they last longer than 25 minutes:
The probability of an event in a continuous distribution is defined by an integral:
The probability of an event in a discrete distribution is defined by a sum:
The CDF and SurvivalFunction of a distribution can be expressed as probabilities:
The survival function for a distribution can be expressed as a probability:
The hazard function for a distribution can be expressed as a probability:
The probability of an impossible event is 0:
The probability of a certain event is 1:
The probability of an arbitrary event must lie between 0 and 1:
Use Probability to find a symbolic expression for the probability of an event:
N[Probability[...]] is equivalent to NProbability if symbolic evaluation fails:
A conditional probability is defined by a ratio of probabilities:
The probability of independent events is the sum of the individual probabilities:
For dependent events one needs to subtract the probability of an intersection event:
Compute the probability of an event:
Obtain the same result using NExpectation:
New in 8