<< Chapter < Page | Chapter >> Page > |
To test your function, generate a sample of
Uniform[0,1]
random variables
using the function
X=rand(1,N)
.
Plot two CDF estimates: one using a sample size
, and one using
.
Plot these functions in the range
t=[-1:0.001:2]
, and on each plot
superimpose the true distribution for a
Uniform[0,1]
random variable.
empcdf
function and the two plots.It is oftentimes necessary to generate samples from a particular distribution. For example, we might want to run simulations to test how an algorithmperforms on noisy inputs. In this section we will address the problem of generating random numbers froma given distribution .
Suppose we have a continuous random variable with distribution , and we form the new random variable . In other words is a function of , and the particular function is the CDF of the random variable .
How is distributed? First notice that is a probability, so that can only take values in the interval .
Since is a monotonically increasing function of , the event is equivalent to if we define . This implies that for ,
Therefore
is uniformly distributed on the interval
[0,1]
.
Conversely, if is a one-to-one function, we may use the inverse transformation to transform a Uniform[0,1] random variable to a random variable with distribution .
Note that combining these results allows us to transform any continuous random variable to any other continuous random variable , provided that is a one-to-one function.
Your task is to use i.i.d. Uniform[0,1] random variables to generatea set of i.i.d. exponentially distributed random variables with CDF
Derive the required transformation.
Generate the
Uniform[0,1]
random variables using the function
rand(1,N)
.
Use your
empcdf
function to plot two CDF estimates for the
exponentially distributed random variables:one using a sample size
, and one using
.
Plot these functions in the range
x=[-1:0.001:2]
, and on each plot
superimpose the true exponential distribution of
[link] .
The statistical properties of a random variable are completely described by its probability density function (assuming it exists, of course).Therefore, it is oftentimes useful to estimate the PDF, given an observation of a random variable.For example, similar to the empirical CDF, probability density estimates may be used to test a proposed model.They may also be used in non-parametric classification problems, where we need toclassify data as belonging to a particular group but without any knowledge of the true underlying class distributions.
Notification Switch
Would you like to follow the 'Purdue digital signal processing labs (ece 438)' conversation and receive update notifications?