<p>When choosing a probability density function for Monte Carlo evaluation of rendering integrals, I get how importance sampling suggests choosing e.g. <span class="math-container">$cos(\theta)$</span> for <span class="math-container">$p(x)$</span>, and then, over say the hemisphere, the normalization constant is <span class="math-container">$1/\pi$</span>, so that the normalized pdf becomes</p>
<p><span class="math-container">\begin{align}
p(x) = \frac{cos(\theta)}{\pi}
\end{align}</span></p>
<p>My question is why does everyone say to draw direction samples from <span class="math-container">$cos(\theta)$</span> distribution rather than <span class="math-container">$cos(\theta)/\pi$</span> distribution? The weight is <span class="math-container">$cos(\theta)/\pi$</span>, so I'd expect the samples to be drawn from <span class="math-container">$cos(\theta)/\pi$</span> as well. (The typical method I see for implementing cos distribution is uniform sampling on a disk and projecting onto hemisphere.)</p>

CC BY-SA 4.0
2022-09-11T22:14:54.603Z
They do mean the $\cos(\theta)/\pi$ probability distribution. It's just a shorthand way of speaking about it to say "the cosine distribution", meaning the distribution whose pdf is proportional to $\cos(\theta)$ and appropriately normalized. (There is no actual distribution whose pdf is just $\cos(\theta)$ without the normalization—that wouldn't be a valid distribution.)
Nathan Reed
CC BY-SA 4.0
2022-09-12T00:02:45.430Z
In fact there's even a product with a sine: $\frac{\cos\theta\sin\theta}{\pi}$ if you were to write the pdf wrt $d\theta d\phi$ instead of $d\omega$. One can go further and take it wrt $d\omega^{\perp}$ in which case it's just $\frac{1}{\pi}$. When people say draw samples according to $\cos\theta$, they mean with probability proportional to $\cos\theta$. The normalization factor is uniquely defined anyways so one can always derive it.
lightxbulb
CC BY-SA 4.0
2022-09-12T16:23:57.383Z
@NathanReed Ah ok but it seems like the directional distribution you get by doing the sampling on the disk and projecting onto hemisphere is only giving you the cos. In the formulas, for example, in Chapter 16 Sampling Transformations Zoo of Ray Tracing Gems, for the hemisphere, they divide by pi when computing the pdf, but the direction vector doesn't seem to account for the divide by pi. Does the direction vector itself just need to be sampled proportional to cos theta?
James B
CC BY-SA 4.0
2022-09-12T17:20:59.457Z
@JamesB Not sure I'm understanding your last question, but the pdf is the thing that's divided by $\pi$. The direction vector should be a unit vector, there's no reason you would scale the actual vector itself by $1/\pi$—that has nothing to do with probabilities.
Nathan Reed
CC BY-SA 4.0
2022-09-13T17:44:40.833Z
@NathanReed So the direction vectors have a distribution; my question is, does this distribution just need to be proportional to cos theta? More generally, does the directional distribution just need to be proportional to the pdf?
James B
CC BY-SA 4.0
2022-09-14T05:52:15.413Z
@JamesB The directional distribution _is_ the pdf. I'm confused what else you think a distribution is?
Nathan Reed
CC BY-SA 4.0
2022-09-14T06:16:04.560Z
To put it another way, the total amount of vectors over the whole hemisphere is always 100% of all the vectors. It can't logically be otherwise. If the pdf is unnormalized then it's telling you that the hemisphere contains 314% of the vectors, which wouldn't make any sense. So the pdf must be normalized to describe the actual distribution of vectors accurately.
Nathan Reed
<pathtracing>
Why does cos sampling directions over hemisphere use cos theta distribution instead of cos theta / pi distribution?
James B
# Why does cos sampling directions over hemisphere use cos theta distribution instead of cos theta / pi distribution?

(Asked by: username_0 on 2022-09-11)

When choosing a probability density function for Monte Carlo evaluation of rendering integrals, I get how importance sampling suggests choosing e.g. $cos(\theta)$ for $p(x)$, and then, over say the hemisphere, the normalization constant is $1/\pi$, so that the normalized pdf becomes

\begin{align}
p(x) = \frac{cos(\theta)}{\pi}
\end{align}

My question is why does everyone say to draw direction samples from $cos(\theta)$ distribution rather than $cos(\theta)/\pi$ distribution? The weight is $cos(\theta)/\pi$, so I'd expect the samples to be drawn from $cos(\theta)/\pi$ as well. (The typical method I see for implementing cos distribution is uniform sampling on a disk and projecting onto hemisphere.)

**Tags:** pathtracing

> **Comments:**
> **username_1**: They do mean the $\cos(\theta)/\pi$ probability distribution. It's just a shorthand way of speaking about it to say "the cosine distribution", meaning the distribution whose pdf is proportional to $\cos(\theta)$ and appropriately normalized. (There is no actual distribution whose pdf is just $\cos(\theta)$ without the normalization—that wouldn't be a valid distribution.)  
> **username_2**: In fact there's even a product with a sine: $\frac{\cos\theta\sin\theta}{\pi}$ if you were to write the pdf wrt $d\theta d\phi$ instead of $d\omega$. One can go further and take it wrt $d\omega^{\perp}$ in which case it's just $\frac{1}{\pi}$. When people say draw samples according to $\cos\theta$, they mean with probability proportional to $\cos\theta$. The normalization factor is uniquely defined anyways so one can always derive it.  
> **username_0**: @username_1 Ah ok but it seems like the directional distribution you get by doing the sampling on the disk and projecting onto hemisphere is only giving you the cos. In the formulas, for example, in Chapter 16 Sampling Transformations Zoo of Ray Tracing Gems, for the hemisphere, they divide by pi when computing the pdf, but the direction vector doesn't seem to account for the divide by pi. Does the direction vector itself just need to be sampled proportional to cos theta?  
> **username_1**: @username_0 Not sure I'm understanding your last question, but the pdf is the thing that's divided by $\pi$. The direction vector should be a unit vector, there's no reason you would scale the actual vector itself by $1/\pi$—that has nothing to do with probabilities.  
> **username_0**: @username_1 So the direction vectors have a distribution; my question is, does this distribution just need to be proportional to cos theta? More generally, does the directional distribution just need to be proportional to the pdf?  
> **username_1**: @username_0 The directional distribution _is_ the pdf. I'm confused what else you think a distribution is?  
> **username_1**: To put it another way, the total amount of vectors over the whole hemisphere is always 100% of all the vectors. It can't logically be otherwise. If the pdf is unnormalized then it's telling you that the hemisphere contains 314% of the vectors, which wouldn't make any sense. So the pdf must be normalized to describe the actual distribution of vectors accurately.  

---

## 0 answers

