<p>I am trying to do the derivation of transforming uniformly distributed 2D points on the unit square into the 2D &quot;tent&quot; distribution below. i.e the standard method of getting the cdf and inversting it.</p>
<p><a href="https://i.sstatic.net/dAeDI.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dAeDI.png" alt="enter image description here" /></a></p>
<p>Peter Shirley has the sampling code for tent funciton in <a href="https://books.google.co.uk/books?id=knpN6mnhJ8QC&amp;pg=PA56&amp;lpg=PA56&amp;dq=importance%20sampling%20of%20triangle%20tent%20function&amp;source=bl&amp;ots=OLbIq51B9B&amp;sig=ACfU3U17KRJrkwjvmEmZA3elroPGDmkTwQ&amp;hl=en&amp;sa=X&amp;ved=2ahUKEwiou6yJ5In4AhVFoVwKHRExAI4Q6AF6BAgsEAM#v=onepage&amp;q=importance%20sampling%20of%20triangle%20tent%20function&amp;f=false" rel="nofollow noreferrer">his book</a> Realistic Ray tracing as this:</p>
<p><a href="https://i.sstatic.net/iNwyS.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/iNwyS.png" alt="enter image description here" /></a></p>
<p>And I am trying to do the derivation of the formula here but somewhere I am making a mistake:</p>
<p>So for the first part t=[-1,0), the cdf is:</p>
<p><a href="https://i.sstatic.net/TmSm5.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TmSm5.png" alt="enter image description here" /></a></p>
<p>But I don't know where I got it wrong. Any idea anyone? Thank you.</p>

CC BY-SA 4.0
2022-05-31T22:47:37.403Z
You forgot the first part in the second expression: $P(t) = \int_{-1}^{t}(1-|\tau|)\,d\tau = \frac{1}{2} + \int_{0}^t(1-\tau)\,d\tau$. I haven't checked whether you have made other mistakes.
lightxbulb
CC BY-SA 4.0
2022-05-31T23:42:12.433Z
pretty sure the second expression is t to 1 but it works out either way
pmw1234
CC BY-SA 4.0
2022-05-31T23:43:44.633Z
@pmw1234 It isn't.
lightxbulb
<sampling><importance-sampling>
Derivation of Sampling 2d Tent Distribution
ali
# Derivation of Sampling 2d Tent Distribution

(Asked by: username_0 on 2022-05-31)

I am trying to do the derivation of transforming uniformly distributed 2D points on the unit square into the 2D "tent" distribution below. i.e the standard method of getting the cdf and inversting it.

[![enter image description here](https://i.sstatic.net/dAeDI.png)](https://i.sstatic.net/dAeDI.png)

Peter Shirley has the sampling code for tent funciton in [his book](https://books.google.co.uk/books?id=knpN6mnhJ8QC&pg=PA56&lpg=PA56&dq=importance%20sampling%20of%20triangle%20tent%20function&source=bl&ots=OLbIq51B9B&sig=ACfU3U17KRJrkwjvmEmZA3elroPGDmkTwQ&hl=en&sa=X&ved=2ahUKEwiou6yJ5In4AhVFoVwKHRExAI4Q6AF6BAgsEAM#v=onepage&q=importance%20sampling%20of%20triangle%20tent%20function&f=false) Realistic Ray tracing as this:

[![enter image description here](https://i.sstatic.net/iNwyS.png)](https://i.sstatic.net/iNwyS.png)

And I am trying to do the derivation of the formula here but somewhere I am making a mistake:

So for the first part t=[-1,0), the cdf is:

[![enter image description here](https://i.sstatic.net/TmSm5.png)](https://i.sstatic.net/TmSm5.png)

But I don't know where I got it wrong. Any idea anyone? Thank you.

**Tags:** sampling, importance-sampling

> **Comments:**
> **username_1**: You forgot the first part in the second expression: $P(t) = \int_{-1}^{t}(1-|\tau|)\,d\tau = \frac{1}{2} + \int_{0}^t(1-\tau)\,d\tau$. I haven't checked whether you have made other mistakes.  
> **username_2**: pretty sure the second expression is t to 1 but it works out either way  
> **username_1**: @username_2 It isn't.  

---

## 0 answers

