ASTR615 Fall 2015 Problem Set #4

Due Wed Nov 4th, 2015

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

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 of an object of density is given by

where represents the volume of the object. Using simple Monte Carlo integration, write a program that computes and its estimated error if , where the volume of the object is defined by , , and . Plot with errorbars as a function of the number of points used in the Monte Carlo integration, for between 10 and , in integer powers of 10.

Massimo Ricotti 2015-10-26