This preview shows page 1. Sign up to view the full content.
Unformatted text preview: tlab functions used to generate random numbers are “makedist” and “random”.
Basically with these two commands one can generate random numbers following
any specified probability density function. For more information, go to:
http://www.mathworks.com/help/stats/random.html?nocookie=true
http://www.mathworks.com/help/stats/makedist.html?nocookie=true Alternatively, one can generate random numbers following any distribution (here we use
triangular distribution as an example) using random numbers from a uniform distribution.
First, we need to find the cumulative distribution function for continuous random
variable.
∫ is probability density function. For a triangular distribution, we have three parameters i.e. min, max, and md (i.e. the
mode). The height of the triangle (corresponding to the PDF) satisfies: For
∫
=
= To get inverse, let Z=∫
5 [ √
For
Z=∫ √ In general, let [ Solve The set of calculated x will follow the distribution specified by F(x). The approach can be visualized using the two figures below.
The red box and green box on yaxis (i.e. F(x)) represents two small ranges with the same
size. For example, we are generating 10,000 numbers following uniform distribution. If
each box represents a range of 0.05, there will be roughly 0.05*10,000=500 numbers in
each box.
By doing inverse, we are trying to determine the positions of corresponding x on xaxis
where
After this, we will see for the same number of points i.e. 500, the red box on xaxis
covers a much large range than the green box (Note both green box and red box contain
500 points). Apparently x is no longer following uniform distribution. The smaller green
box represents a region where we have high “show up” frequency, which is in agreement
with the specified PDF. What we did in fact is to reduce the range covered by the
green/red box to a very small number (i.e. from 0.05 to 0.0001 so only one point showing
up in each box). 6 Z=F(x)
1.0 x 0 h x
min 7 md max...
View
Full
Document
This note was uploaded on 02/18/2014 for the course ME 597 taught by Professor Staff during the Fall '07 term at Purdue UniversityWest Lafayette.
 Fall '07
 Staff

Click to edit the document details