Matlab functionalities
Discrete distribution functions
Uniform
unidrnd(N)randomly generates an integer between1andN.
So if you want to generate the rolling result obtained by a fair die, just type
unidrnd(6)
To generate a vector of n such trials, you can use:
n = 100
unidrnd(6, 1, n)
unidpdf(x, N)provides the probability of the outcomexhappening in the case of a discrete uniform distribution between1toN.
For example, the probability that rolling a fair die gives a 1 is given by
unidpdf(1, 6)
unidcdf(x, N)gives the probability of obtaining an outcome less or equal thatxfor a discrete uniform distribution between1toN.
For example, the probability of obtaining a number between 1 and 3 after rolling a faire die can be computed with
unidcdf(3, 6)
unidinv(P, N)provides the smallest integerksuch that the probability of obtaining an outcome between1andkis greater or equal toP.
For instance, the smallest integer k such that at least 60% of the outcomes generated by a fair die are between 1 and k is given by
unidinv(0.60, 6)
Binomial
binornd(N, p)generates from the binomial distribution a possible number of successes out ofNtrials, each of which has a probability of successp.
To illustrate this, a possible number of times a fair coin is flipped as heads out of 100 trials is given by
binornd(100, 0.5)
binopdf(x, N, p)gives the probability of obtainingxsuccesses out ofNtrials, each of which has a probability of success ofp.
In the example of flipping coins, the probability of observing tails 60 times after 100 flipping trials of a fair coin is provided by
binopdf(60, 100, 0.5)
binocdf(x, N, p)gives the probability of observing at mostxsuccesses out ofNtrials, each of which has a probability of success ofp.
In the example of flipping coins, the probability of obtaining tails at most 60 times after 100 flipping trials of a fair coin is provided by
binocdf(60, 100, 0.5)
binoinv(P, N, p)gives the smallest integerksuch that the probability of obtaining between0andksuccesses afterNtrials -- each of which has a probability of success ofp-- is greater or equal toP.
For example, the smallest integer k such that at least 40% of the time, generating 100 trials provides a number of heads between 0 and k is given by
binoinv(0.40, 100, 0.5)
Poisson
poissrnd(mu)generates a random number from the Poisson distribution of parametermu.poisspdf(x, mu)gives the probability of obtainingxfrom the Poisson distribution of parametermu.poisscdf(x, mu)gives the probability of observing a value between0andxfrom the Poisson distribution of parametermupoissinv(P, mu)gives the smallest integerksuch that the probability of obtaining a value between0andkfrom the Poisson distribution of parametermuis greater or equal toP.
Continuous distribution functions
Uniform
unifrnd(x_min, x_max)randomly generates a real number between the valuesx_minandx_max.unifpdf(x, x_min, x_max)returns the value atxof the probability density function of the continuous uniform distribution with boundsx_minandx_max.unifcdf(x, x_min, x_max)returns the probability that the continuous uniform distribution with boundsx_minandx_maxyields a value of at mostx.unifinv(P, x_min, x_max)gives the valuexsuch that the continuous uniform distribution with boundsx_minandx_maxhas a probability of exactlyPto yield outcomes that are less or equal thanx.
Normal
normrnd(mu, sigma)generates a random number from the Gaussian distribution of meanmuand standard deviationsigma.normpdf(x, mu, sigma)returns the value atxof the probability density function of the Gaussian distribution of meanmuand standard deviationsigma.normcdf(x, mu, sigma)returns the probability that a random number drawn from the Gaussian distribution of meanmuand standard deviationsigmahas a value of at mostx.norminv(P, mu, sigma)gives the valuexsuch that the Gaussian distribution of meanmuand standard deviationsigmahas a probability of exactlyPto yield outcomes that are less or equal thanx.
Exponential
exprnd(lambda)generates a random number from the exponential distribution of parameterlambda.exppdf(x, lambda)returns the value atxof the probability density function of the exponential distribution of parameterlambda.expcdf(x, lambda)returns the probability that a random number drawn from the exponential distribution of parameterlambdahas a value of at mostx.expinv(P, lambda)gives the valuexsuch that the exponential distribution of parameterlambdahas a probability of exactlyPto yield outcomes that are less or equal thanx.
CME 106 - Probability and Statistics for Engineers