 # Course-related Matlab functionalities

## Discrete distribution functions

#### Uniform

• unidrnd(N) randomly generates an integer between 1 and N.

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 outcome x happening in the case of a discrete uniform distribution between 1 to N.

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 that x for a discrete uniform distribution between 1 to N.

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 integer k such that the probability of obtaining an outcome between 1 and k is greater or equal to P.

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 of N trials, each of which has a probability of success p.

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 obtaining x successes out of N trials, each of which has a probability of success of p.

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 most x successes out of N trials, each of which has a probability of success of p.

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 integer k such that the probability of obtaining between 0 and k successes after N trials -- each of which has a probability of success of p -- is greater or equal to P.

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 parameter mu.

• poisspdf(x, mu) gives the probability of obtaining x from the Poisson distribution of parameter mu.

• poisscdf(x, mu) gives the probability of observing a value between 0 and x from the Poisson distribution of parameter mu

• poissinv(P, mu) gives the smallest integer k such that the probability of obtaining a value between 0 and k from the Poisson distribution of parameter mu is greater or equal to P.

## Continuous distribution functions

#### Uniform

• unifrnd(x_min, x_max) randomly generates a real number between the values x_min and x_max.

• unifpdf(x, x_min, x_max) returns the value at x of the probability density function of the continuous uniform distribution with bounds x_min and x_max.

• unifcdf(x, x_min, x_max) returns the probability that the continuous uniform distribution with bounds x_min and x_max yields a value of at most x.

• unifinv(P, x_min, x_max) gives the value x such that the continuous uniform distribution with bounds x_min and x_max has a probability of exactly P to yield outcomes that are less or equal than x.

#### Normal

• normrnd(mu, sigma) generates a random number from the Gaussian distribution of mean mu and standard deviation sigma.

• normpdf(x, mu, sigma) returns the value at x of the probability density function of the Gaussian distribution of mean mu and standard deviation sigma.

• normcdf(x, mu, sigma) returns the probability that a random number drawn from the Gaussian distribution of mean mu and standard deviation sigma has a value of at most x.

• norminv(P, mu, sigma) gives the value x such that the Gaussian distribution of mean mu and standard deviation sigma has a probability of exactly P to yield outcomes that are less or equal than x.

#### Exponential

• exprnd(lambda) generates a random number from the exponential distribution of parameter lambda.

• exppdf(x, lambda) returns the value at x of the probability density function of the exponential distribution of parameter lambda.

• expcdf(x, lambda) returns the probability that a random number drawn from the exponential distribution of parameter lambda has a value of at most x.

• expinv(P, lambda) gives the value x such that the exponential distribution of parameter lambda has a probability of exactly P to yield outcomes that are less or equal than x.