Statistics [25]: From Uniform to General Distributions

1 minute read

Published:

General practice of converting a uniform distribution to a general distribution.

Theorem

Assume , function is a monotone increasing function, and for ,

Then, the probability distribution function of is .

Example 1

Generate an exponential distribution with parameter from uniform distribution .

Firstly, the probability distrbution function of the exponential function is

It can be easily verified that is a monotone increasing function, hence

which can be used to generate random number conforming an exponential distribution with parameter .

To test this,

This proved the conclusion.

# uniform to exponential
lambdaE = 1
x = np.random.random(10000)
y = -np.log(1-x)/lambdaE
plt.hist(y,bins=50)
plt.show()

drawing

Example 2 - Box-Muller Method

Assume are independent, make the transform and , then are also independent and follow the standard normal distribution.

Proof is easy and is thus omitted here.

# uniform to normal
x = np.random.random(10000)
y = np.random.random(10000)
U = (-2*np.log(x))**0.5*np.cos(2*np.pi*y)
V = (-2*np.log(x))**0.5*np.sin(2*np.pi*y)

plt.figure()
plt.hist(U,bins=50)
plt.title('U')
plt.show()

plt.figure()
plt.hist(V,bins=50)
plt.title('V')
plt.show()

drawing

drawing

Von Neumann Rejection Sampling

Generate random numbers with probability density function .

Suppose that we know an upper bound for and a proposal distribution , so that there is such that .

Here is the algorithm:

Draw a sample u ~ U[0,1]
Draw a sample x ~ q(x)
if p(x) / (cq(x)) >= u then
  accept x
else
  reject it and repeat
endif

Theorem

Assume and , and are independent, then

Proof. Use the law of total probability.


Table of Contents

Comments