Previous Up Next

18.3.3  Sampling from probability distributions

Generating random numbers from binomial distribution.

The randbinomial command finds random numbers chosen according to the binomial distribution (see Section 18.4.3).

Example

randbinomial(100,0.4)
     
42           
Generating random numbers from multinomial distribution.

The randmultinomial command finds random numbers chosen according to a multinomial distribution (see Section 18.4.5).

Examples

randmultinomial([1/2, 1/3, 1/6])
     
1           
randmultinomial([1/2, 1/3, 1/6],["R","V","B"])
     
“R”           
Generating random numbers from Poisson distribution.

Recall that given a number λ>0, the corresponding Poisson distribution P(λ) satisfies

  Prob(X ≤ k)=e−λ
λk
k!
.

It will have mean λ and standard deviation √λ. (See also Section 18.4.6.)

The randpoisson command finds a random integer according to a Poisson distribution.

Example

randpoisson(10.6)
     
16           
Generating random numbers from normal distribution.

The randnorm or randNorm command chooses a random number according to a normal distribution.

Example

randnorm(2,1)
     
3.39283224858           
Generating random numbers from Student’s distribution.

The randstudent command finds random numbers chosen according to Student’s distribution (see Section 18.4.8).

Example

randstudent(5)
     
0.268225314184           
Generating random numbers from χ2 distribution.

The randchisquare command finds random numbers chosen according to the χ2 distribution (see Section 18.4.9).

Example

randchisquare(5)
     
4.53970828547           
Generating random numbers from Fisher-Snédécor distribution.

The randfisher command finds random numbers chosen according to the Fisher-Snédécor distribution (see Section 18.4.10).

Example

randfisher(2,3)
     
2.33137725333           
Generating random numbers from gamma distribution.

The randgammad command finds random numbers chosen according to the gamma distribution (see Section 18.4.11).

Example

randgammad(3,1)
     
4.91461463472           
Generating random numbers from beta distribution.

The randbetad command finds random numbers chosen according to the beta distribution (see Section 18.4.12).

Example

randbetad(2,3)
     
0.524453873081           
Generating random numbers from geometric distribution.

The randgeometric command finds random numbers chosen according to the geometric distribution (see Section 18.4.13).

Example

randgeometric(0.2)
     
11           
Generating random numbers from exponential distribution.

The randexp command finds random numbers chosen according to the exponential distribution (see Section 18.4.15).

Example

randexp(2.1)
     
0.0288626239833           

Previous Up Next