*u*and

_{1}*u*are independent random variables that are uniformly distributed between 0 and 1 and let

_{2}then

*z*and

_{1}*z*are independent random variables with a standard normal distribution. Intuitively, the transformation maps each circle of points around the origin to another circle of points around the origin where larger outer circles are mapped to closely-spaced inner circles and inner circles to outer circles.

_{2}Let's see a Python snippet that implements the transformation:

from numpy import random, sqrt, log, sin, cos, pi from pylab import show,hist,subplot,figure # transformation function def gaussian(u1,u2): z1 = sqrt(-2*log(u1))*cos(2*pi*u2) z2 = sqrt(-2*log(u1))*sin(2*pi*u2) return z1,z2 # uniformly distributed values between 0 and 1 u1 = random.rand(1000) u2 = random.rand(1000) # run the transformation z1,z2 = gaussian(u1,u2) # plotting the values before and after the transformation figure() subplot(221) # the first row of graphs hist(u1) # contains the histograms of u1 and u2 subplot(222) hist(u2) subplot(223) # the second contains hist(z1) # the histograms of z1 and z2 subplot(224) hist(z2) show()The result should be similar to the following:

In the first row of the graph we can see, respectively, the histograms of

*u*and

_{1}*u*before the transformation and in the second row we can see the values after the transformation, respectively

_{2}*z*and

_{1}*z*. We can observe that the values before the transformation are distributed uniformly while the histograms of the values after the transformation have the typical Gaussian shape.

_{2}
## No comments:

## Post a Comment