<p>To derive the expression for uniformly selecting a point within a solid angle bounded in right ascension, <span class="math-container">$\alpha_{min} \leq \alpha \leq \alpha_{max}$</span> and declination, <span class="math-container">$\delta_{min} \leq \delta \leq \delta_{max}$</span>, we start with the definition for the differential element of solid angle:
<span class="math-container">$$d\Omega = \cos\delta d\delta\ d\alpha$$</span></p>
<p>As observed in the question, the right ascension is uniformly distributed between the upper and lower bounds, <span class="math-container">$\alpha \sim U(\alpha_{min}, \alpha_{max})$</span>.  This now leaves the distribution of declination to be determined along a narrow &quot;slice&quot; or constant right ascension.</p>
<p>Borrowing from <a href="https://astronomy.stackexchange.com/questions/22388/generate-an-uniform-distribution-on-the-sky">Generate an uniform distribution on the sky</a>:
<span class="math-container">$$dP = \cos\delta d\delta$$</span></p>
<p>The cumulative distribution function (CDF)of selecting a point at a specific declination is then given by:
<span class="math-container">$$P(\delta) = \frac{\int_{\delta_{min}}^{\delta} \cos\delta' \,d\delta'}{\int_{\delta_{min}}^{\delta_{max}} \cos\delta' \,d\delta'}$$</span></p>
<p><span class="math-container">$$P(\delta) =
\frac{\left.\sin\delta\right|_{\delta_{min}}^{\delta}}{\left.\sin\delta\right|_{\delta_{min}}^{\delta_{max}}} =
\frac{\sin\delta-\sin\delta_{min}}{\sin\delta_{max}-\sin\delta_{min}}$$</span></p>
<p>The CDF maps the declination to a quantile, <span class="math-container">$v$</span>, between 0 and 1 : <span class="math-container">$P(\delta)=v$</span>.  We can then substitute <span class="math-container">$v$</span> for <span class="math-container">$P(\delta)$</span>, solve for <span class="math-container">$\delta$</span> and arrive at an inverse CDF mapping <span class="math-container">$v$</span> to the declination.</p>
<p><span class="math-container">$$v = \frac{\sin\delta-\sin\delta_{min}}{\sin\delta_{max}-\sin\delta_{min}}$$</span></p>
<p>Now solving for <span class="math-container">$\delta$</span>
<span class="math-container">$$v\left(\sin\delta_{max}-\sin\delta_{min}\right) = \sin\delta-\sin\delta_{min}$$</span></p>
<p><span class="math-container">$$\sin\delta = v\left(\sin\delta_{max}-\sin\delta_{min}\right)+\sin\delta_{min}$$</span></p>
<p><span class="math-container">$$\delta = \arcsin\left(v\left(\sin\delta_{max}-\sin\delta_{min}\right)+\sin\delta_{min}\right)$$</span></p>
<p>The desired distribution in declination is then realize by letting <span class="math-container">$v \sim U(0, 1)$</span>.  This is equivalent to:
<span class="math-container">$$\delta = \arcsin(u)$$</span>
where <span class="math-container">$u \sim U(\sin\delta_{min}, sin\delta_{\max})$</span></p>

CC BY-SA 4.0
2022-03-22T23:29:50.797Z
just fyi I've added a different method with a more uniform and less random distribution in [this answer](https://astronomy.stackexchange.com/a/48892/7982)
uhoh
CC BY-SA 4.0
2022-02-20T20:22:33.227Z
2022-02-20T20:22:33.227Z
GrapefruitIsAwesome
<p>I have an analog question of this one : <a href="https://astronomy.stackexchange.com/questions/22388/generate-an-uniform-distribution-on-the-sky">Generate an uniform distribution on the sky</a></p>

<p>I generate an uniform distribution on the sky, but just a patch of it, with $$\alpha_{min} \leq \alpha \leq \alpha_{max}$$ and 
$$\delta_{min} \leq \delta \leq \delta_{max}$$</p>

<p>for Right Ascention, I just have to take uniform distribution between $\alpha_{min}$and $ \alpha_{max}$. </p>

<p>For declination it works if I take $$\delta_{random} = \sin^{-1}\left( \mathrm{Uniform}(\sin\delta_{min},\, \sin\delta_{max}) \right)$$</p>

<p>My problem is that I don't know how to demonstrate this formula for the generation of delinations. Any idea how to make the proof of this formula ?</p>

<p>I saw in <a href="https://astronomy.stackexchange.com/questions/22388/generate-an-uniform-distribution-on-the-sky">Generate an uniform distribution on the sky</a> @RobJeffries post which gives an expression of $P(\delta)$ and demonstrates that $\delta = \sin^{-1}(2P-1)$ where $P$ is a random number between 0 and 1, which is compatible to my formula with $\delta_{min} = -\frac{\pi}{2}$ and $ \delta_{max} = +\frac{\pi}{2}$, but I was not able to generalize his demonstration.</p>

<p>Thanks in advance for your help!</p>

CC BY-SA 4.0
2018-06-28T11:12:45.087Z
Can you explain a little more exactly what you are looking for in an answer? "*Any idea how to demonstrate this formula ?*" Are you looking for a proof, or a test, or how to use it?
uhoh
CC BY-SA 4.0
2018-06-28T12:57:28.943Z
Hi, thanks for your answer, yes I am looking for a proof. I found this formula making tests, ans it works, but I have no clue how to make a proof of it. I mean how to prove $\delta_{random} = \sin^{-1}\left( \mathrm{Uniform}(\sin\delta_{min},\, \sin\delta_{max}) \right)$
AlbertBranson
CC BY-SA 4.0
2018-06-28T13:31:23.180Z
Okay, yes I think the idea is quite reasonable and will work (I haven't checked the details). Since the mapping is monotonic, if you are throwing away the results outside your limits, it's safe to throw away the random numbers that would lead there as well; I think the *monotonicity* is probably central to a proof. You might consider asking in [math.stackexchange.com](https://math.stackexchange.com/) instead of here for a better discussion of math and proofs.
uhoh
CC BY-SA 4.0
2022-03-22T23:29:43.907Z
just fyi I've added a different method with a more uniform and less random distribution in [this answer](https://astronomy.stackexchange.com/a/48892/7982)
uhoh
<coordinate><positional-astronomy><mathematics>
Generate an uniform distribution on the sky between limits
AlbertBranson
# Generate an uniform distribution on the sky between limits

(Asked by: username_0 on 2018-06-27)

I have an analog question of this one : [Generate an uniform distribution on the sky](https://astronomy.stackexchange.com/questions/22388/generate-an-uniform-distribution-on-the-sky)

I generate an uniform distribution on the sky, but just a patch of it, with $$\alpha\_{min} \leq \alpha \leq \alpha\_{max}$$ and
$$\delta\_{min} \leq \delta \leq \delta\_{max}$$

for Right Ascention, I just have to take uniform distribution between $\alpha\_{min}$and $ \alpha\_{max}$.

For declination it works if I take $$\delta\_{random} = \sin^{-1}\left( \mathrm{Uniform}(\sin\delta\_{min},\, \sin\delta\_{max}) \right)$$

My problem is that I don't know how to demonstrate this formula for the generation of delinations. Any idea how to make the proof of this formula ?

I saw in [Generate an uniform distribution on the sky](https://astronomy.stackexchange.com/questions/22388/generate-an-uniform-distribution-on-the-sky) @RobJeffries post which gives an expression of $P(\delta)$ and demonstrates that $\delta = \sin^{-1}(2P-1)$ where $P$ is a random number between 0 and 1, which is compatible to my formula with $\delta\_{min} = -\frac{\pi}{2}$ and $ \delta\_{max} = +\frac{\pi}{2}$, but I was not able to generalize his demonstration.

Thanks in advance for your help!

**Tags:** coordinate, positional-astronomy, mathematics

> **Comments:**
> **username_1**: Can you explain a little more exactly what you are looking for in an answer? "*Any idea how to demonstrate this formula ?*" Are you looking for a proof, or a test, or how to use it?  
> **username_0**: Hi, thanks for your answer, yes I am looking for a proof. I found this formula making tests, ans it works, but I have no clue how to make a proof of it. I mean how to prove $\delta_{random} = \sin^{-1}\left( \mathrm{Uniform}(\sin\delta_{min},\, \sin\delta_{max}) \right)$  
> **username_1**: Okay, yes I think the idea is quite reasonable and will work (I haven't checked the details). Since the mapping is monotonic, if you are throwing away the results outside your limits, it's safe to throw away the random numbers that would lead there as well; I think the *monotonicity* is probably central to a proof. You might consider asking in [math.stackexchange.com](https://math.stackexchange.com/) instead of here for a better discussion of math and proofs.  
> **username_1**: just fyi I've added a different method with a more uniform and less random distribution in [this answer](https://astronomy.stackexchange.com/a/48892/7982)  

---

## 1 answers

### Answer by username_2 on 2022-02-20. Score: 2

To derive the expression for uniformly selecting a point within a solid angle bounded in right ascension, $\alpha\_{min} \leq \alpha \leq \alpha\_{max}$ and declination, $\delta\_{min} \leq \delta \leq \delta\_{max}$, we start with the definition for the differential element of solid angle:
$$d\Omega = \cos\delta d\delta\ d\alpha$$

As observed in the question, the right ascension is uniformly distributed between the upper and lower bounds, $\alpha \sim U(\alpha\_{min}, \alpha\_{max})$. This now leaves the distribution of declination to be determined along a narrow "slice" or constant right ascension.

Borrowing from [Generate an uniform distribution on the sky](https://astronomy.stackexchange.com/questions/22388/generate-an-uniform-distribution-on-the-sky):
$$dP = \cos\delta d\delta$$

The cumulative distribution function (CDF)of selecting a point at a specific declination is then given by:
$$P(\delta) = \frac{\int\_{\delta\_{min}}^{\delta} \cos\delta' \,d\delta'}{\int\_{\delta\_{min}}^{\delta\_{max}} \cos\delta' \,d\delta'}$$

$$P(\delta) =
\frac{\left.\sin\delta\right|\_{\delta\_{min}}^{\delta}}{\left.\sin\delta\right|\_{\delta\_{min}}^{\delta\_{max}}} =
\frac{\sin\delta-\sin\delta\_{min}}{\sin\delta\_{max}-\sin\delta\_{min}}$$

The CDF maps the declination to a quantile, $v$, between 0 and 1 : $P(\delta)=v$. We can then substitute $v$ for $P(\delta)$, solve for $\delta$ and arrive at an inverse CDF mapping $v$ to the declination.

$$v = \frac{\sin\delta-\sin\delta\_{min}}{\sin\delta\_{max}-\sin\delta\_{min}}$$

Now solving for $\delta$
$$v\left(\sin\delta\_{max}-\sin\delta\_{min}\right) = \sin\delta-\sin\delta\_{min}$$

$$\sin\delta = v\left(\sin\delta\_{max}-\sin\delta\_{min}\right)+\sin\delta\_{min}$$

$$\delta = \arcsin\left(v\left(\sin\delta\_{max}-\sin\delta\_{min}\right)+\sin\delta\_{min}\right)$$

The desired distribution in declination is then realize by letting $v \sim U(0, 1)$. This is equivalent to:
$$\delta = \arcsin(u)$$
where $u \sim U(\sin\delta\_{min}, sin\delta\_{\max})$

> **Comments:**
> **username_1**: just fyi I've added a different method with a more uniform and less random distribution in [this answer](https://astronomy.stackexchange.com/a/48892/7982)  

---

