# Bivariate transformation using CDF method

1. Dec 3, 2015

### rabbed

If I have the following relations:
X = sqrt(1-V^2)*cos(U)
Y = sqrt(1-V^2)*sin(U)
Z = V
where (-pi < U < pi) and (-1 < V < 1) are independent random variables, both with uniform distributions.
How do I use the CDF method to find X_pdf(x)?
X_pdf(x) =
X_cdf'(x) =
( P( X < x ) )' =
( P( sqrt(1-V^2)*cos(U) < x ) )' = ?

2. Dec 4, 2015

### haruspex

Can you see how to write that as a condition on V, and hence as an integral wrt u?

3. Dec 5, 2015

### rabbed

As a first step, is this correct?

( P( sqrt(1-V^2) < x/cos(U) ) )' =
( P( 1-V^2 < (x/cos(U))^2 ) )' =
( P( -1+V^2 > -(x/cos(U))^2 ) )' =
( P( V^2 > 1-(x/cos(U))^2 ) )' =
( P( |V| > sqrt(1-(x/cos(U))^2) ) )' =
( P( -V > sqrt(1-(x/cos(U))^2) OR V > sqrt(1-(x/cos(U))^2) ))' =
( P( V < -sqrt(1-(x/cos(U))^2) OR V > sqrt(1-(x/cos(U))^2) ))' = ?

Then i think i should make a 2D graph with V as Y-axis and U as X-axis, drawing:

V1 = sqrt(1-(x/cos(U))^2)
V2 = -sqrt(1-(x/cos(U))^2)

By solving 1-(x/cos(U))^2 < 0
i get that the functions are imaginary when
pi*n + arccos(x) < U < pi*n + arccos(-x) for some n
and real when
pi*(n-1) + arccos(-x) <= U <= pi*n + arccos(x) for some n
For there to be at least one real solution i need to limit (-1 <= x <= 1)

I think the volume i should be calculating is a double integral of the joint distribution
of U and V, which is 1/(1-(-1)) * 1/(pi-(-pi)) = 1/(4*pi)?
And i should get the integration limits by solving some inequality using the 2D graph?

Sorry for my bad skills, my only source is the internet :)

Last edited: Dec 5, 2015
4. Dec 5, 2015

### haruspex

fine up to there, went a bit wrong after that.
But now use that V has a uniform distribution on (-1,1).
You will need to do something with the U, though, Bringing in an integral involving u, the value of U.

5. Dec 5, 2015

### rabbed

Sorry, i'm lost :(
Do you mean that the expression 1-(x/cos(U))^2 also has uniform distribution on (-1,1) and if I evaluate the integral of the expression on U/u within those limits it would equal 1?
Is the graphing i described above another way to do this or have i misunderstood that?

6. Dec 5, 2015

### haruspex

No.
Suppose the value of U is in (u, u+du). You can write down the probability of that. Now 1-(x/cos(u))^2 is just a value, and you know from the uniform distribution of V the probability that |V| exceeds that.
You need to consider, in a sense, all the possible values of U, the probability (density) of that value, and the probability of the value of V meeting that condition. Then you sum these up (integrate).
For any two r.v.s X, Y, $P(Y>X)=\int P(Y>x).dF_X(x)$.

7. Dec 7, 2015

### rabbed

Ok, my interpretation of what you said:

P(u < U < u+du) = U_cdf(u+du)-U_cdf(u) = U_pdf(u)*du

P(|V| > sqrt(1-(x/cos(U))^2)) = 1-V_cdf(sqrt(1-(x/cos(U))^2)) =
1 - integral wrt v from -1 to sqrt(1-(x/cos(U))^2) of V_pdf(v) =
1 - (1/2*(sqrt(1-(x/cos(U))^2)) - 1/2*(-1)) =
1/2*(1 - sqrt(1-(x/cos(U))^2))

integral wrt u from -pi to pi of
1/2*(1-sqrt(1-(x/cos(U))^2)) * U_pdf(u)*du =
1/(4*pi)*(1-sqrt(1-(x/cos(U))^2)) * du

that integral gave me a nasty result.. :)

what am i calculating? the joint probability that U=u and V=v in the relation X = sqrt(1-V^2)*cos(U)?

8. Dec 11, 2015

### rabbed

Hope someone can advice me how to proceed with this?

9. Dec 11, 2015

### haruspex

Sorry, I forgot to come back to this. Thanks for the nudge.
You have a few Us that should be u, but other than that you are on the right lines.
The integral is correct, but gives the CDF of X. You want the PDF. If you could solve the integral then you could find the PDF from the CDF, but there is another route. What can you do instead?

10. Dec 12, 2015

### rabbed

Thanks for coming back :)
I think you are referring to directly derivate the integral without evaluating the integral?

But I guess in this case it's different since I need to derivate a double integral?
I read something about Leibniz integral rule, is that what i should use?

Another thing is bugging me:
P(|V| > sqrt(1-(x/cos(U))^2)) = 1-V_cdf(sqrt(1-(x/cos(U))^2))
I think it's only valid to say that if we have V instead of |V| in the left hand side?
Graphing |y|>sqrt(1-(c/cos(x))^2) with c variable between -1 and 1 on this page: https://www.desmos.com/calculator
the area is both above and below the "circle", so I'm wondering if this is correct:

P(|V| > sqrt(1-(x/cos(U))^2)) =
P(V < -sqrt(1-(x/cos(U))^2) OR V > sqrt(1-(x/cos(U))^2)) =
P(V < -sqrt(1-(x/cos(U))^2)) + P(V > sqrt(1-(x/cos(U))^2)) =
V_cdf(-sqrt(1-(x/cos(U))^2)) + (1-V_cdf(sqrt(1-(x/cos(U))^2)))

with V_pdf(v) = 1/2 (-1 < v < 1) and by symmetry we get
V_cdf(-sqrt(1-(x/cos(U))^2)) = (1-V_cdf(sqrt(1-(x/cos(U))^2)))
so that
P(|V| > sqrt(1-(x/cos(U))^2)) = 2*(1-V_cdf(sqrt(1-(x/cos(U))^2))) ?

11. Dec 12, 2015

### haruspex

It's not a double integral, but yes, it's the Leibniz integral rule you need. The link you posted does not cover it.
So what integral do you get after differentiating? Can you solve it?
Wrt V and |V|, the easiest is to realise that you only care about |V|, and that is uniform on (0,1).

12. Dec 12, 2015

### rabbed

I was thinking it was double generally, including the integral wrt v also.

Hm, seems I failed somewhere:

I(x) = integral wrt u from -pi to pi of 1/(4*pi)*(1-sqrt(1-(x/cos(u))^2)) * du

I'(x) = d[I(x)]/dx =
integral wrt u from -pi to pi of d[1/(4*pi)*(1-sqrt(1-(x/cos(u))^2))]/dx * du =
integral wrt u from -pi to pi of x/(4*Pi*cos^2(u)*sqrt(1-(x/cos(u))^2)) * du =
[ -sqrt(1-(x/cos(u))^2)/(4*Pi) ] wrt u from -pi to pi =
-sqrt(1-(x/cos(pi))^2)/(4*Pi) + sqrt(1-(x/cos(-pi))^2)/(4*Pi) =
0

13. Dec 12, 2015

### haruspex

First, there's a step I missed out. We need to fix up the range of integration. When cos(u)<x the integrand (before differentiation) makes no sense. The probability of |V| being negative is zero, so the integration range should be truncated. Also, by symmetry, we only need to consider positive u. Cos(-u)=cos(u). This leads to an integration for the cdf from 0 to arccos(x) (which I'll call y below).
As a result, when differentiating, you get another term courtesy of the fundamental theorem of calculus. But that term is not an integral, so presents no difficulty.
This leaves us with the core issue of integrating $\int_0^y\frac{\sec^2(u).du}{\sqrt{1-x^2\sec^2(u)}}$.
sec2 plays nicely with tan, both directly and via calculus. So try t=tan(u).

14. Dec 14, 2015

### rabbed

Just to check that we're on the same page.

So first you made a change in the integral range wrt v:
P(|V| > sqrt(1-(x/cos(U))^2)) = 1-V_cdf(sqrt(1-(x/cos(u))^2)) =
1 - integral wrt v from 0 to sqrt(1-(x/cos(u))^2) of V_pdf(v) =
1 - [x/2] wrt v from 0 to sqrt(1-(x/cos(u))^2) =
1 - (sqrt(1-(x/cos(u))^2/2 - 0) = 1-1/2*sqrt(1-(x/cos(u))^2

And then you made a change in the integral range wrt u:
I(x) = integral wrt u from 0 to arccos(x) of 1/(4*pi)*(1-1/2*sqrt(1-(x/cos(u))^2) * du

Which gives us:
I'(x) = d[I(x)]/dx =
integral wrt u from 0 to arccos(x) of d[1/(4*pi)*(1-1/2*sqrt(1-(x/cos(u))^2)]/dx * du =
integral wrt u from 0 to arccos(x) of x*sec^2(u)/(8*pi*sqrt(1-(x/cos(u))^2)) * du

There is a mismatch between our integrals where I have x*sec^2(u) in the nominator, you only have sec^2(u).
Also I assume you moved the constant 8*Pi from the denominator outside the integral sign?

Meanwhile, I'm brushing up my integration skills..

15. Dec 14, 2015

### haruspex

You really will have to get into LaTeX.
Yes, I have an x in the numerator, but it's just a constant as far as the integral is concerned. Same with the pi etc.

16. Dec 15, 2015

### rabbed

17. Dec 15, 2015

### haruspex

I started again from the top and realised we need to be more careful about ranges.
By symmetry, we can restrict U to the range (0,pi/2) and V to the range (0,1). This will give the distribution for |X|.
Doing this, I found that the term that comes from the fundamental theorem of calculus cancels with another term, leaving only the integral:
$\frac 2{\pi}\int_{u=0}^{arccos(x)}\frac{x\sec^2(u).du}{\sqrt{1-x^2\sec^2(u)}}$
t = tan(u):
$\frac 2{\pi}\int_{t=0}^{\frac 1x\sqrt{1-x^2}}\frac{xdt}{\sqrt{1-x^2-x^2t^2}}$
s=xt/sqrt(1-x2):
$\frac 2{\pi}\int_{s=0}^1\frac{ds}{\sqrt{1-s^2}}$
s=sin(theta):
$\frac 2{\pi}\int_{\theta=0}^{\pi/2}1.d\theta = 1$
Sure enough, when I simulate it in a spreadsheet I see a uniform distribution.

18. Dec 15, 2015

### haruspex

I felt there should be a much simpler geometric path to the answer, and there is.
Using the method Archimedes employed to show that the surface area of a sphere is the same as that of the enclosing cylinder, we can see that the given distributions of U and V are equivalent to a uniform distribution over the surface of a sphere with coordinates X, Y and Z=V. Rotating the cylinder's axis around, it follows immediately that X and Y also have uniform distributions.

19. Dec 17, 2015

### rabbed

So you're saying that X_pdf(x) = Y_pdf(y) = Z_pdf(z) = 1/2?
That's awesome, thank you so much for your help!
I will try to calculate Y_pdf(y) by myself, just for the practice. This is one of the trickiest topics i've come across in math so far.
Thanks again!

20. Dec 17, 2015

### haruspex

The pdf of X would normally be written fX(x), etc., but yes. Did you understand the geometry argument? There should be some way to turn it into algebra, but I've not tried.