Page 1 of 1
Bivariate Normal Distribution in Matlab
Posted: October 1st, 2004, 4:19 pm
by janickg
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.
Bivariate Normal Distribution in Matlab
Posted: October 1st, 2004, 6:40 pm
by gileper
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
Bivariate Normal Distribution in Matlab
Posted: October 1st, 2004, 6:44 pm
by janickg
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.
Bivariate Normal Distribution in Matlab
Posted: October 1st, 2004, 7:07 pm
by gileper
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
Bivariate Normal Distribution in Matlab
Posted: October 1st, 2004, 7:13 pm
by AVt
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 ...
Bivariate Normal Distribution in Matlab
Posted: October 1st, 2004, 7:24 pm
by janickg
ARe you sure a transformation may be applied to the pdf function of the bivariate normal? Have you seen the equation?
Bivariate Normal Distribution in Matlab
Posted: October 1st, 2004, 11:41 pm
by actuaryck
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".
Bivariate Normal Distribution in Matlab
Posted: October 2nd, 2004, 3:13 pm
by SPAAGG
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)
Bivariate Normal Distribution in Matlab
Posted: October 2nd, 2004, 3:14 pm
by SPAAGG
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.
Bivariate Normal Distribution in Matlab
Posted: October 4th, 2004, 7:09 am
by actuaryck
Does anyone know which is a more efficient way to generate multivariate normal random numbers in Matlab: by the function "mvnrnd()" or Cholesky decomposition?
Bivariate Normal Distribution in Matlab
Posted: October 4th, 2004, 12:34 pm
by janickg
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.