Question 23.6: Suppose that we would like to select some random data points......

Suppose that we would like to select some random data points that are uniformly distributed on a circular disk having a radius of 1. See Figure 23.34 for a picture of what the disk looks like. If the PDF governing the distribution of data on the disk is given by P(r) = 2r = D, where D is the diameter of the disk, write a computer program to generate 1000 random data points located on the disk.

23.34
Step-by-Step
The 'Blue Check Mark' means that this solution was answered by an expert.
Learn more on how do we answer questions.

In this case, the PDF governing the distribution of the data points is P(r) = 2r. The cumulative probability distribution function (or CDF) in this case is C(r) = ∫P(r)dr = r². The inverse CDF is r = \sqrt{C} = \sqrt{u}. Now suppose that we use the function rand () to randomly select values for u between 0 and 1.The random values of the radius are then r = \sqrt{(rand())} and the angle corresponding to each data point is θ = 2π rand (). Therefore, the program required to generate each data point is

For (i = 1; i ≤ 1000; i++)
(

r = sqrt (rand ());
θ = 2π rand ();
x = r cos θ
y = r sin θ
p(i) = (x, y)

)

The result of implementing this code snippet is shown in Figure 23.34. Notice how uniformly the data points are distributed within the circle that defines the outer boundary of the disk. In this case, the code snippet was called several hundred times in succession to create the distribution of data points shown.

Related Answered Questions