# Verifying the expression for a Gaussian laser beam distribution.

This section describes how to verify that our expression for a Gaussian laser beam distribution is accurate. This example is calculated using MATLAB: listing of MATLAB program.

## Generate a histogram of r1 values from a set of random numbers.

The computer uses a random number generator to generate a set of N=10,000 random numbers referred to as RND. This set of RND is then converted into a set of r1 values using the expression r1 = w*sqrt(-ln(RND)).

Make a histogram of this set of r1 values using the MATLAB expression [n,x] = hist(r1,nb) which describes the number (n) of r1 values which fall into the bin centered at x, where there are nb bins. The bin size is specified: dx = x(3) - x(2).

Normalize n by N to yield the fraction of the total in a bin, then normalize by dx to yield a probability density function, p(r1). The integral of p(r1)dr1 over all r is approximated by the MATLAB expression sum(p*dx) which equals unity as it should.

Finally, for the sake of easy recognition by you, the reader, we divide p(r1) by the term (2 pi r1) to yield the Gaussian distribution of photon launch along a radial line extending out from the origin.

## Create analytic p(r1)/(2 pi r1)

For comparison, create an analytic expression for a Gaussian curve:

y = exp(-r2/w2)/(pi*w2)

which is equivalent to p(r1)/(2 pi r1).

## Plot the histogram and analytic expressions.

The following figure plots the normalized histogram (yellow circles) generated by the random number generator and the analytic expression (red line):

IN SUMMARY, the normalized histogram agrees with the analytic expression illustrating that the Monte Carlo expression, r1 = w*sqrt(-ln(RND)), is correct.

back to article