next up previous
Next: About this document ...

ASTR415/688C Spring 2005 Problem Set #4


Due April 7, 2005


This problem set focuses on random number generation and Monte Carlo integration.

  1. Write a function that transforms a uniform deviate into a Rayleigh distributed deviate described by

    \begin{displaymath}
p(y)\,dy = y e^{-y^2/2}\,dy,\ y \ge 0.
\end{displaymath}

    Generate a suitable number of deviates and plot a normalized histogram to test your function (plot the expected Rayleigh distribution over your histogram for comparison).

  2. The total mass $M$ of an object of density $\rho$ is given by

    \begin{displaymath}
M = \int_V \rho\,dx\,dy\,dz ,
\end{displaymath}

    where $V$ represents the volume of the object. Using simple Monte Carlo integration, write a program that computes $M$ and its estimated error $\sigma_M$ if $\rho = 1 + x^2 + 3(y + z)^2$, where the volume of the object $V$ is defined by $x^2 + y^2 + z^2 \le 9$, $x \ge 0$, and $y \ge -1$. Plot $M$ with errorbars $\sigma_M$ as a function of the number of points $N$ used in the Monte Carlo integration, for $N$ between 10 and $10^7$, in integer powers of 10.





Derek C. Richardson 2005-03-17