To calculate the cartesian coordinates for scattering rays over a hemisphere based on cosine-weighted importance sampling, one method can be to obtain the marginal and conditional PDF for the polar coordinates $\varphi$ and $\theta$. Following the whole procedure, I obtained:

$$ p(\theta) = \int_0^{2\pi} p(\theta, \varphi) \mathrm{d}\varphi = \int_0^{2\pi} p(w) \ sin\theta d\phi = 2 \, \pi \, sin \theta \, f(\theta) = 2 sin\theta cos\theta $$

$$ p(\varphi) = \frac{p(\theta, \varphi)}{p(\theta)} = \frac{1}{2\pi} $$

where $w$ is the solid angle and $f(\theta) = \frac{cos\theta}{\pi}$.

Now, every book explains how to draw samples based on $p(\theta)$ and $p(\varphi)$ from a uniform random generator $\xi$.This is obtained calculating the CDF for both distributions.

My question is:

Why is this last step necessary? Is it because it's efficient/convenient in coding, since there are uniform random generators already implemented in the majority of libraries? Thanks

  • $\begingroup$ Yes, because we know how to generate uniformly distributed samples efficiently, and we can transform those to other desired distributions. $\endgroup$ – lightxbulb Nov 2 '19 at 19:10
  • $\begingroup$ @lightxbulb Thank you! $\endgroup$ – maurock Nov 2 '19 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.