Register to reply

Matlab and Mathematica can't do this integration

by ay0034
Tags: cdf, integration, mathematica, matlab, pdf
Share this thread:
ay0034
#1
Jun21-11, 04:01 PM
P: 11
Hello,

While doing a research, I obtained the following PDF:



[itex]f_{Z}[/itex][itex](z)=\frac{1}{2\pi\sigma^{2}_{1}\sigma^{2}_{2}}[/itex][itex]e^{-\frac{1}{2} ( \frac{\mu^{2}_{1}}{\sigma^{2}_{1}} + \frac{\mu^{2}_{2}}{\sigma^{2}_{2}})}[/itex][itex]\int^{2\pi}_{0}ze^{-\frac{1}{2\sigma^{2}_{1}\sigma^{2}_{2}}\{ \sigma^{2}_{2}z^{2}cos^{2}\theta+ \sigma^{2}_{1}z^{2}sin^{2}\theta-2\sigma^{2}_{2}\mu_{1}zcos\theta-2\sigma^{2}_{1}\mu_{2}zsin\theta \} }[/itex]



This integral won't be in a closed form. In addition to that, I have to integrate this PDF to get a CDF. Since this PDF is what I calculated, I want to check the CDF is going to be 1 as z goes to infinity.

However, both matlab and mathematica cannot integrate this PDF. Please help me with this annoying integration.

I appreciated it in advance.
Phys.Org News Partner Science news on Phys.org
Sapphire talk enlivens guesswork over iPhone 6
Geneticists offer clues to better rice, tomato crops
UConn makes 3-D copies of antique instrument parts
ay0034
#2
Jun21-11, 04:04 PM
P: 11
mu's and sigma's can be any number. And in this case, mu1 and mu2 are different, and sig1 and sig2 are different as well.
Stephen Tashi
#3
Jun21-11, 07:45 PM
Sci Advisor
P: 3,252
With respect to which variable is the integration to be performed? [itex] dz [/itex] ?, [itex] d\theta [/itex] ?

Stephen Tashi
#4
Jun21-11, 09:51 PM
Sci Advisor
P: 3,252
Matlab and Mathematica can't do this integration

If your interest is only [itex] \int_{-\infty}^{\infty} f_Z(z) dz [/itex] have you tried changing the order of integration?

Let [itex] h(z,\theta) = [/itex] the messy function you are dealing with.

Taking some liberties with limits and the order of integration, which you would need to justify, we have:

[tex] \int_{-\infty}^{\infty} f_Z(z)dz = \lim_{a \rightarrow \infty} \int_{-a}^{a} f_Z(z) dz [/tex]

[tex] = \lim_{a \rightarrow \infty} \int_{-a}^{a} \int_{0}^{2\pi} h(z,\theta) d\theta\ dz [/tex]

[tex] = \int_{0}^{2\pi} \left( \lim_{a \rightarrow \infty} \int_{-a}^{a} h(z,\theta)\ dz \right) \ d\theta [/tex]
ay0034
#5
Jun21-11, 10:48 PM
P: 11
Oh i forgot to put that. It's dtheta, not dz.

And I have tried what you are talking about, and I got no good results. Since the integration does not have a closed form, replacing it with a and using limit function was not helpful.
Stephen Tashi
#6
Jun21-11, 11:46 PM
Sci Advisor
P: 3,252
Quote Quote by ay0034 View Post
Since the integration does not have a closed form.
Which integration does not have a closed form?
[tex] \int z e^{C_1 z^2 + C_2 z} dz [/tex] ?
ay0034
#7
Jun21-11, 11:53 PM
P: 11
Both of them. With respect to theta and with respect to z.
Stephen Tashi
#8
Jun22-11, 01:02 PM
Sci Advisor
P: 3,252
In the problem you are working, can you rescale the random variables so that the means of the rescaled variables are 0 and their standard deviations are 1 ?
ay0034
#9
Jun22-11, 01:05 PM
P: 11
Unfortunately, I can't. If so, my PDF would be a Rayleigh distribution and I can take advantage of existing information out there. That is my problem.
disregardthat
#10
Jun22-11, 01:41 PM
Sci Advisor
P: 1,741
wrt z you could get the answer in terms of the error-function, if you want that.
ay0034
#11
Jun22-11, 01:46 PM
P: 11
You're right. The thing is I have to integrate that error function with respect to theta. I almost gave up to do this double integration, and am trying to calculate mean and variance. But without a closed form PDF, that looks impossible as well.
Stephen Tashi
#12
Jun22-11, 01:55 PM
Sci Advisor
P: 3,252
I'm trying to relate this problem to your thread on "Chi or Rayleigh or Ricean?". It looks like you are transforming to polar coordinates by X = z cos(theta) , Y = z sin(theta). Does the z in front of the exponential come from the volume element for polar coordinate integration? If so, isn't this calculation for a CDF rather than a PDF ? (I'm just guessing about your intentions.)
ay0034
#13
Jun22-11, 02:07 PM
P: 11
Yes, the PDF I wrote down is already transformed to a polar coordinates. And z you refered to came from the fact that dxdy is transformed to r*drd[itex]\theta[/itex].

As you know, this is kind of a function of r.v., I began with a CDF, transformed it to a polar coordinates, and took derivative of the CDF with respect to z so I get a PDF.

Matlab can numerically calculate values of PDF at each point, but cannot integrate it numerically nor symbolically.
winterfors
#14
Jun23-11, 03:56 AM
P: 71
As far as I can see, your integrand is only the product of two normal distributions over x and y, i.e. a bivariate normal distribution with zero covariance. Why do you want to express this in polar coordinates? The integral from from z=0 to infinity will indeed be equal to one, of course very easily demonstrated in cartesian coordinates.

If you absolutely want to express it in polar coordinates, the expression will be quite simple (with simple analytical expressions for the primitive functions of integrals) if you set mu_1 and mu_2 as the centre of your polar coordinates.
Stephen Tashi
#15
Jun23-11, 09:05 AM
Sci Advisor
P: 3,252
Quote Quote by winterfors View Post
Why do you want to express this in polar coordinates?
http://www.physicsforums.com/showthread.php?t=507750
winterfors
#16
Jun23-11, 04:43 PM
P: 71
Quote Quote by ay0034 View Post
...am trying to calculate mean and variance. But without a closed form PDF, that looks impossible as well.
Are you only after the mean and variance? In that case, I would not bother trying to calculate the distribution over Z, but just numerically evaluate the mean and variance of Z by integrating over X and Y (will work fine for any values of means and variances of the two normal distributions)
Pyrrhus
#17
Jun28-11, 01:56 PM
HW Helper
Pyrrhus's Avatar
P: 2,279
I didn't check the integrand, but if it does not have a closed form, and you want a numeric value then your alternatives are quadrature or simulation. The integral is one-dimensional? then Quadrature should work fine.


Register to reply

Related Discussions
MATLAB and Mathematica help Math & Science Software 0
Matlab vs mathematica Math & Science Software 20
How write the 'for' loop in mathematica Math & Science Software 11
How to write matlab code in mathematica Math & Science Software 0
Matlab/Mathematica help! Math & Science Software 1