<< 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
$N=20$ , and one using
$N=200$ .
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 ${F}_{X}\left(x\right)$ .
Suppose we have a continuous random variable $X$ with distribution ${F}_{X}\left(x\right)$ , and we form the new random variable $Y={F}_{X}\left(X\right)$ . In other words $Y$ is a function of $X$ , and the particular function is the CDF of the random variable $X$ .
How is $Y$ distributed? First notice that ${F}_{X}(\xb7)$ is a probability, so that $Y$ can only take values in the interval $[0,1]$ .
Since ${F}_{X}\left(x\right)$ is a monotonically increasing function of $x$ , the event $\{Y\le y\}$ is equivalent to $\{X\le x\}$ if we define $y={F}_{X}\left(x\right)$ . This implies that for $0\le y\le 1$ ,
Therefore
$Y$ is uniformly distributed on the interval
[0,1]
.
Conversely, if ${F}_{X}(\xb7)$ is a one-to-one function, we may use the inverse transformation ${F}_{X}^{-1}\left(U\right)$ to transform a Uniform[0,1] random variable $U$ to a random variable with distribution ${F}_{X}(\xb7)$ .
Note that combining these results allows us to transform any continuous random variable $X\sim {F}_{X}\left(x\right)$ to any other continuous random variable $Z\sim {F}_{Z}\left(z\right)$ , provided that ${F}_{Z}(\xb7)$ 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
$N=20$ , and one using
$N=200$ .
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?