<p>As lightxbulb mentioned in the comments, one confusing thing here is that two different functions are being called <span class="math-container">$p$</span>. Kind of like function overloading in C++, the <span class="math-container">$p(\omega)$</span> and <span class="math-container">$p(\theta, \phi)$</span> are two different functions, in the sense of having different domains and different dependence on their inputs, though in some sense they abstractly represent the same distribution.</p>
<p>The other thing that's confusing here is that the values returned by these functions are not just numbers. Since these are probability density functions, their values carry units of inverse area. Moreover, the two functions are expressing density with respect to different areas: <span class="math-container">$p(\omega)$</span> is probability per area on the unit sphere, while <span class="math-container">$p(\theta, \phi)$</span> is probability per unit area on the <span class="math-container">$\theta$</span>-<span class="math-container">$\phi$</span> plane—an abstract 2D plane formed by <span class="math-container">$\theta$</span> and <span class="math-container">$\phi$</span> as Cartesian coordinates (just like the <span class="math-container">$x$</span>-<span class="math-container">$y$</span> plane). These area measures are related to each other, but not the same: as you observed, <span class="math-container">$d\omega = \sin \theta \, d\theta \, d\phi$</span>.</p>
<p>Notation like <span class="math-container">$d\omega$</span> and <span class="math-container">$d\theta \, d\phi$</span> refers to these area measures. As mentioned in the comments, this can be mathematically formalized as differential forms (<a href="https://www.math.purdue.edu/%7Earapura/preprints/diffforms.pdf" rel="nofollow noreferrer">here's an introduction</a> I found useful).</p>
<p>Because <span class="math-container">$p(\omega)$</span> is a probability density per area on the unit sphere, if <span class="math-container">$d\omega$</span> is a &quot;small&quot; area on the unit sphere around the point <span class="math-container">$\omega$</span>, then <span class="math-container">$p(\omega) \, d\omega$</span> works out to be a probability—not a density, but just a plain old probability number. In the limit of <span class="math-container">$d\omega$</span> being infinitesimal, <span class="math-container">$p(\omega) \, d\omega$</span> is the amount of probability enclosed within the area <span class="math-container">$d\omega$</span>.</p>
<p>Similarly <span class="math-container">$p(\theta, \phi) \, d\theta \, d\phi$</span> is the amount of probability enclosed within a &quot;small&quot; area of the <span class="math-container">$\theta$</span>-<span class="math-container">$\phi$</span> plane. The statement that
<span class="math-container">$$
p(\omega) \, d\omega = p(\theta, \phi) \, d\theta \, d\phi
$$</span>
is intended to mean the following: the amount of probability in a small area of the unit sphere is equal to the amount of probability in the corresponding small area of the <span class="math-container">$\theta$</span>-<span class="math-container">$\phi$</span> plane. In other words, probability is conserved by mapping between these two domains. This is the condition that makes these two functions represent &quot;the same&quot; distribution, abstractly, despite being parameterized with different variables.</p>
<p>The condition needs to be written that way because the probability densities aren't unitless numbers. If we had some function whose values were just plain numbers without units attached, and we wanted to reparameterize it with different variables, the condition would just be that <span class="math-container">$f(\omega) = f(\theta, \phi)$</span>: the function should keep the same value at &quot;the same&quot; point when we change variables. But with the probability densities, we don't want the same value of the function, we want the same amount of probability in each part of the domain.</p>
<p>Using this &quot;conservation of probability&quot; condition <span class="math-container">$p(\omega) \, d\omega = p(\theta, \phi) \, d\theta \, d\phi$</span> together with the relationship between the two area measures, <span class="math-container">$d\omega = \sin \theta \, d\theta \, d\phi$</span>, we can derive:
<span class="math-container">$$
p(\theta, \phi) = p(\omega) \, \sin \theta
$$</span>
which shows that to express the a spherical distribution in terms of <span class="math-container">$\theta, \phi$</span>, you have to not only change variables but also multiply the function by <span class="math-container">$\sin \theta$</span> to conserve the probability. That <span class="math-container">$\sin \theta$</span> factor is known as the &quot;inverse Jacobian&quot;, and it accounts for how the transformation stretches the area in different parts of the domain.</p>

CC BY-SA 4.0
2022-09-26T22:46:25.607Z
This makes things so much clearer! I definitely was not seeing $p(\theta, \phi)$ in a Cartesian plane prior to this, and also now I understand why units for the density function must be (in this case) inverse area, because multiplying them by little areas cancels, to yield unitless probabilities. Super helpful!
James B
CC BY-SA 4.0
2022-09-24T22:30:26.637Z
2022-09-24T22:30:26.637Z
Nathan Reed
<p>In the Monte Carlo chapter of PBRT, in the section <a href="https://www.pbr-book.org/3ed-2018/Monte_Carlo_Integration/Transforming_between_Distributions" rel="nofollow noreferrer">Transforming Between Distributions</a>, they say &quot;The density with respect to <span class="math-container">$\theta$</span> and <span class="math-container">$\phi$</span> can therefore be derived&quot;, but they <em>start</em> with</p>
<p><span class="math-container">\begin{align}
p(\theta, \phi) \ d\theta \ d\phi = p(\omega) \ d\omega
\end{align}</span></p>
<p>and my question is, how to see that this is true? I get how, if you are ok with that, then substituting <span class="math-container">$d\omega = \sin \theta \ d\theta \ d\phi$</span> gives the result that follows, but I don't understand how to even read that starting line, like is it saying &quot;the function defined with respect to <span class="math-container">$\theta$</span> and <span class="math-container">$\phi$</span> times <span class="math-container">$d\theta$</span> times <span class="math-container">$d\phi$</span> is equal to the function defined with respect to <span class="math-container">$\omega$</span> times <span class="math-container">$d\omega$</span>&quot;?</p>
<p>Anyway, it seems like it should instead be</p>
<p><span class="math-container">\begin{align}
p(\omega) \ d\omega = p(\theta, \phi) \sin \theta \ d\theta \ d\phi
\end{align}</span></p>
<p>according to section 5.5? (Express function in terms of <span class="math-container">$\theta$</span> and <span class="math-container">$\phi$</span> and use <span class="math-container">$d\omega = \sin \theta \ d\theta \ d\phi$</span>.)</p>

CC BY-SA 4.0
2022-09-18T21:10:33.873Z
It is two functions. One is defined wrt $d\omega$, let's call it $p_{\omega}$ and the other wrt $d\phi d\theta$ let's call it $p_{s}$. Then by equating the expressions you get the relationship.
lightxbulb
CC BY-SA 4.0
2022-09-19T02:02:36.183Z
What is $p(\omega) d\omega$ by itself though? I've never seen a function written this way, like we're not integrating it or anything, we're just writing $p(\omega) d\omega$. What does that even mean? This just seems like an abuse of the notation or something.
James B
CC BY-SA 4.0
2022-09-19T03:40:11.523Z
I found someone else confused about the EXACT same issue, so thankfully it's not just me, but sadly, there is no clear answer there:
https://computergraphics.stackexchange.com/questions/5267/2d-sampling-with-multidimensional-transformations
The poster there says:
In the book, to find p(θ,ϕ) they state that p(θ,ϕ)dθdϕ=p(ω)dω, but why?
He actually repeats his question multiple times, and while good info is provided, that question doesn't ever seem to get answered. I've also seen other resources, such as scratchapixel, just use that equality exactly as in the PBRT book, so no help there...
James B
CC BY-SA 4.0
2022-09-19T09:41:23.087Z
$p(\omega)d\omega$ is a differential form, it is not abuse of notation. Essentially  you want to find the expression of a probability density with respect to different measures. By definition a probability density function $f$ must be non-negative and integrate to $1$. Now assume you are given a pdf $f$ wrt the solid angle measure. Then you know that $\int_{\Omega}f(\omega)d\omega=1$. Now using $d\omega = |\sin\theta|d\theta d\phi$ you get  $\int_{0}^{2\pi}\int_{0}^{\pi/2}f(\omega)|\sin\theta|d\theta d\phi=1$. So a function proportional to $f$ that integtates to $1$ is $g = f |\sin\theta|$.
lightxbulb
CC BY-SA 4.0
2022-09-19T15:36:47.457Z
@lightxbulb Ah ok, I see now, I think I was getting lost in the weeds of notation. Now I see what they meant in the other answer when they said $\sin \theta$ is included inside $p(\theta, \phi)$, as $p(\theta, \phi)$ is your $f(\omega) |\sin \theta|$ term. Earlier, I did end up with the last double integral you just wrote, but I was getting confused because it seemed weird to have a function of $\omega$ inside integrals over $\theta$ and $\phi$, but again that seems to be just a notational thing. Thank you.
James B
CC BY-SA 4.0
2022-09-19T16:27:05.667Z
$\omega$ is just notation for a unit vector. E.g. you can define it using $\theta$ and $\phi$ as $\omega = R(\sin\theta\cos\phi, \sin\theta\sin\phi, \cos\theta)$, where $R$ is a rotation matrix that orients this to match the upper hemisphere at the intersection point. Here $d\omega$ refers to the surface measure on the unit sphere, typically it is expanded wrt spherical coordinates as $|\sin\theta|d\theta d\phi$, however you could also express it wrt Cartesian coords as $\delta(\|(x,y,z)\|-1)dx dy dz$, so the $\omega$ part is used to remain agnostic (discussed somewhere in Veach's thesis).
lightxbulb
<monte-carlo>
Transforming between solid angle and spherical angle distribution in PBRT
James B
# Transforming between solid angle and spherical angle distribution in PBRT

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

In the Monte Carlo chapter of PBRT, in the section [Transforming Between Distributions](https://www.pbr-book.org/3ed-2018/Monte_Carlo_Integration/Transforming_between_Distributions), they say "The density with respect to $\theta$ and $\phi$ can therefore be derived", but they *start* with

\begin{align}
p(\theta, \phi) \ d\theta \ d\phi = p(\omega) \ d\omega
\end{align}

and my question is, how to see that this is true? I get how, if you are ok with that, then substituting $d\omega = \sin \theta \ d\theta \ d\phi$ gives the result that follows, but I don't understand how to even read that starting line, like is it saying "the function defined with respect to $\theta$ and $\phi$ times $d\theta$ times $d\phi$ is equal to the function defined with respect to $\omega$ times $d\omega$"?

Anyway, it seems like it should instead be

\begin{align}
p(\omega) \ d\omega = p(\theta, \phi) \sin \theta \ d\theta \ d\phi
\end{align}

according to section 5.5? (Express function in terms of $\theta$ and $\phi$ and use $d\omega = \sin \theta \ d\theta \ d\phi$.)

**Tags:** monte-carlo

> **Comments:**
> **username_1**: It is two functions. One is defined wrt $d\omega$, let's call it $p_{\omega}$ and the other wrt $d\phi d\theta$ let's call it $p_{s}$. Then by equating the expressions you get the relationship.  
> **username_0**: What is $p(\omega) d\omega$ by itself though? I've never seen a function written this way, like we're not integrating it or anything, we're just writing $p(\omega) d\omega$. What does that even mean? This just seems like an abuse of the notation or something.  
> **username_0**: I found someone else confused about the EXACT same issue, so thankfully it's not just me, but sadly, there is no clear answer there: https://computergraphics.stackexchange.com/questions/5267/2d-sampling-with-multidimensional-transformations The poster there says: In the book, to find p(θ,ϕ) they state that p(θ,ϕ)dθdϕ=p(ω)dω, but why? He actually repeats his question multiple times, and while good info is provided, that question doesn't ever seem to get answered. I've also seen other resources, such as scratchapixel, just use that equality exactly as in the PBRT book, so no help there...  
> **username_1**: $p(\omega)d\omega$ is a differential form, it is not abuse of notation. Essentially  you want to find the expression of a probability density with respect to different measures. By definition a probability density function $f$ must be non-negative and integrate to $1$. Now assume you are given a pdf $f$ wrt the solid angle measure. Then you know that $\int_{\Omega}f(\omega)d\omega=1$. Now using $d\omega = |\sin\theta|d\theta d\phi$ you get  $\int_{0}^{2\pi}\int_{0}^{\pi/2}f(\omega)|\sin\theta|d\theta d\phi=1$. So a function proportional to $f$ that integtates to $1$ is $g = f |\sin\theta|$.  
> **username_0**: @username_1 Ah ok, I see now, I think I was getting lost in the weeds of notation. Now I see what they meant in the other answer when they said $\sin \theta$ is included inside $p(\theta, \phi)$, as $p(\theta, \phi)$ is your $f(\omega) |\sin \theta|$ term. Earlier, I did end up with the last double integral you just wrote, but I was getting confused because it seemed weird to have a function of $\omega$ inside integrals over $\theta$ and $\phi$, but again that seems to be just a notational thing. Thank you.  
> **username_1**: $\omega$ is just notation for a unit vector. E.g. you can define it using $\theta$ and $\phi$ as $\omega = R(\sin\theta\cos\phi, \sin\theta\sin\phi, \cos\theta)$, where $R$ is a rotation matrix that orients this to match the upper hemisphere at the intersection point. Here $d\omega$ refers to the surface measure on the unit sphere, typically it is expanded wrt spherical coordinates as $|\sin\theta|d\theta d\phi$, however you could also express it wrt Cartesian coords as $\delta(\|(x,y,z)\|-1)dx dy dz$, so the $\omega$ part is used to remain agnostic (discussed somewhere in Veach's thesis).  

---

## 1 answers

### Answer by username_2 on 2022-09-24. Score: 4 | Accepted answer

As username_1 mentioned in the comments, one confusing thing here is that two different functions are being called $p$. Kind of like function overloading in C++, the $p(\omega)$ and $p(\theta, \phi)$ are two different functions, in the sense of having different domains and different dependence on their inputs, though in some sense they abstractly represent the same distribution.

The other thing that's confusing here is that the values returned by these functions are not just numbers. Since these are probability density functions, their values carry units of inverse area. Moreover, the two functions are expressing density with respect to different areas: $p(\omega)$ is probability per area on the unit sphere, while $p(\theta, \phi)$ is probability per unit area on the $\theta$-$\phi$ plane—an abstract 2D plane formed by $\theta$ and $\phi$ as Cartesian coordinates (just like the $x$-$y$ plane). These area measures are related to each other, but not the same: as you observed, $d\omega = \sin \theta \, d\theta \, d\phi$.

Notation like $d\omega$ and $d\theta \, d\phi$ refers to these area measures. As mentioned in the comments, this can be mathematically formalized as differential forms ([here's an introduction](https://www.math.purdue.edu/%7Earapura/preprints/diffforms.pdf) I found useful).

Because $p(\omega)$ is a probability density per area on the unit sphere, if $d\omega$ is a "small" area on the unit sphere around the point $\omega$, then $p(\omega) \, d\omega$ works out to be a probability—not a density, but just a plain old probability number. In the limit of $d\omega$ being infinitesimal, $p(\omega) \, d\omega$ is the amount of probability enclosed within the area $d\omega$.

Similarly $p(\theta, \phi) \, d\theta \, d\phi$ is the amount of probability enclosed within a "small" area of the $\theta$-$\phi$ plane. The statement that
$$
p(\omega) \, d\omega = p(\theta, \phi) \, d\theta \, d\phi
$$
is intended to mean the following: the amount of probability in a small area of the unit sphere is equal to the amount of probability in the corresponding small area of the $\theta$-$\phi$ plane. In other words, probability is conserved by mapping between these two domains. This is the condition that makes these two functions represent "the same" distribution, abstractly, despite being parameterized with different variables.

The condition needs to be written that way because the probability densities aren't unitless numbers. If we had some function whose values were just plain numbers without units attached, and we wanted to reparameterize it with different variables, the condition would just be that $f(\omega) = f(\theta, \phi)$: the function should keep the same value at "the same" point when we change variables. But with the probability densities, we don't want the same value of the function, we want the same amount of probability in each part of the domain.

Using this "conservation of probability" condition $p(\omega) \, d\omega = p(\theta, \phi) \, d\theta \, d\phi$ together with the relationship between the two area measures, $d\omega = \sin \theta \, d\theta \, d\phi$, we can derive:
$$
p(\theta, \phi) = p(\omega) \, \sin \theta
$$
which shows that to express the a spherical distribution in terms of $\theta, \phi$, you have to not only change variables but also multiply the function by $\sin \theta$ to conserve the probability. That $\sin \theta$ factor is known as the "inverse Jacobian", and it accounts for how the transformation stretches the area in different parts of the domain.

> **Comments:**
> **username_0**: This makes things so much clearer! I definitely was not seeing $p(\theta, \phi)$ in a Cartesian plane prior to this, and also now I understand why units for the density function must be (in this case) inverse area, because multiplying them by little areas cancels, to yield unitless probabilities. Super helpful!  

---

