Wednesday, November 4, 2009

Populating the Sphere

I am trying to populate the randoms in the same way that the data is populated over the sphere. This means that in right ascension I populate the randoms with a uniform distribution over the range of the data values. However, for declination I populate using a cosine function (because we want to density per volume element to be constant). I am doing the following:
oo = 1;
while(oo){
thisdec = drand48()*mask; // Choose a declination inside the mask
theta = drand48(); //Choose a random value for sin(thisdec)
/*If theta is "below the sin(thisdec) curve",
keep thisdec, otherwise repeat above process. */
if(theta < sin(thisdec){
Rb[nn].pos[i] = thisdec;
oo = 0;
}

}

This uses a rejection sampling method to populate the declinations. It seem to work, here are plots of the random distributions compared with the data, you can see that the distributions match:







Matching distributions of data (red) and randoms (blue)

Just to make sure that the data still falls in the same regions as the randoms here are more plots:







The data (red) falls in the same physical region as the randoms (blue)

Now my correlation function matches Alexia's again (as opposed to my October 30th post):


Matching 3D correlation functions!

No comments:

Post a Comment