Serving the Quantitative Finance Community

 
User avatar
janickg
Topic Author
Posts: 0
Joined: August 3rd, 2004, 1:13 pm

Bivariate Normal Distribution in Matlab

October 1st, 2004, 4:19 pm

Anyone here familiar with this distribution? I know that Matlab doesn't have strong support for multivariate distributions, but I need to work with the bivariate normal distribution. My approach is 1. I have specified the pdf.2. I need to calculate probabilities from this distribution (analytically - not using Monte Carlo)3. I need to perform double integration on the pdf, but with -inf limits.The quad or dblquad function doesn't seem to like this. Is there any other approach to solving this? Perhaps a different numerical method?Suggestions and hints would be helpful.
 
User avatar
gileper
Posts: 0
Joined: October 26th, 2002, 11:26 am

Bivariate Normal Distribution in Matlab

October 1st, 2004, 6:40 pm

I think you should truncate the domain. Instead of -inf try -100.Then use -50 and you 'll see that if the function is "stable enough", then the result is almost equal. You have to find the right truncation in terms of computational speed and good accurancy.For "Stable enough" ..I mean not with respect to the more or less fatness of the tail.You should be much more cautious if (f.i.) the tails have a periodic behavior that exponentially goes to zero ...Matlab is powerful, however you could use Maple or Mathematica
 
User avatar
janickg
Topic Author
Posts: 0
Joined: August 3rd, 2004, 1:13 pm

Bivariate Normal Distribution in Matlab

October 1st, 2004, 6:44 pm

I realize that Maple and Mathematica have better support for multinormal distributions, at least Mathematica i know for sure as I use it as well. However for a problem I am working on, I am constraint to using the Matlab IDE. I thought about using your approach, and still am investigating alternatives within the bounds of Matlab.Thanks very much.
 
User avatar
gileper
Posts: 0
Joined: October 26th, 2002, 11:26 am

Bivariate Normal Distribution in Matlab

October 1st, 2004, 7:07 pm

transform (a to Inf) to ]0,1] using z=1/(x-a+1)for example integral{from 2 to infinity} f(x) dx set z=1/(x-a+1) gives x=1+1/z dx = -1/(z^2) dz hence integral{from 2 to infinity} f(x) dx = integral{from 0 to 1 } f(1+1/z) /z^2 dz
 
User avatar
AVt
Posts: 90
Joined: December 29th, 2001, 8:23 pm

Bivariate Normal Distribution in Matlab

October 1st, 2004, 7:13 pm

If it really does not exist (can not believe that) you may make your translation from code at http://www.sci.wsu.edu/math/faculty/genz/homepage (or search for contributions of Graeme here, but i am somewhat unsure whether he posted that). At least Maple is slow for that ...
 
User avatar
janickg
Topic Author
Posts: 0
Joined: August 3rd, 2004, 1:13 pm

Bivariate Normal Distribution in Matlab

October 1st, 2004, 7:24 pm

ARe you sure a transformation may be applied to the pdf function of the bivariate normal? Have you seen the equation?
 
User avatar
actuaryck
Posts: 0
Joined: September 30th, 2004, 8:29 am

Bivariate Normal Distribution in Matlab

October 1st, 2004, 11:41 pm

QuoteOriginally posted by: janickgAnyone here familiar with this distribution? I know that Matlab doesn't have strong support for multivariate distributions, but I need to work with the bivariate normal distribution. My approach is 1. I have specified the pdf.2. I need to calculate probabilities from this distribution (analytically - not using Monte Carlo)3. I need to perform double integration on the pdf, but with -inf limits.The quad or dblquad function doesn't seem to like this. Is there any other approach to solving this? Perhaps a different numerical method?Suggestions and hints would be helpful.You problem seems like what people are doing in Bayesian inference. You might want to google "Monte Carlo integration" and "Gibbs sampling".
 
User avatar
SPAAGG
Posts: 3
Joined: March 21st, 2003, 1:31 pm

Bivariate Normal Distribution in Matlab

October 2nd, 2004, 3:13 pm

Many algorithm exist to simulate a bivariate normal. I would use 1. Cholesky decomposition. You decompose the var.cov matrix via CC', Cholesky decomposition. Then, you simulate 2 indep normal draws N(0,1) z, and then, create the vector x = mean + C * z2. Gibbs sampling (Casella and Greenberg)
 
User avatar
SPAAGG
Posts: 3
Joined: March 21st, 2003, 1:31 pm

Bivariate Normal Distribution in Matlab

October 2nd, 2004, 3:14 pm

Many algorithms exist to simulate a bivariate normal. I would use 1. Cholesky decomposition. You decompose the var.cov matrix via CC', Cholesky decomposition. Then, you simulate 2 indep normal draws N(0,1) z, and then, create the vector x = mean + C * z2. Gibbs sampling (Casella and Greenberg)3. IMSL libraries.
 
User avatar
actuaryck
Posts: 0
Joined: September 30th, 2004, 8:29 am

Bivariate Normal Distribution in Matlab

October 4th, 2004, 7:09 am

Does anyone know which is a more efficient way to generate multivariate normal random numbers in Matlab: by the function "mvnrnd()" or Cholesky decomposition?
 
User avatar
janickg
Topic Author
Posts: 0
Joined: August 3rd, 2004, 1:13 pm

Bivariate Normal Distribution in Matlab

October 4th, 2004, 12:34 pm

I am aware of the simulation methods, and there are many for this. Though I was more interested in solving the double integrals of the pdf. This has been very informative, thanks all. :-)