Illustration

Course-related Matlab functionalities

By Afshine Amidi and Shervine Amidi

Discrete distribution functions

Uniform

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)

For example, the probability that rolling a fair die gives a 1 is given by

unidpdf(1, 6)

For example, the probability of obtaining a number between 1 and 3 after rolling a faire die can be computed with

unidcdf(3, 6)

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

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)

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)

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)

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

Continuous distribution functions

Uniform

Normal

Exponential