Marginal Density from a joint DIstribution
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mo
el 7 de Ag. de 2012
Comentada: Antonio Marino
el 19 de Nov. de 2020
Hey, I have a really simple question. How can I obtain a marginal density fx(x) from a joint distribution (x,y) ? In my case the joint distribution follows a log-normal distribution. I cannot use Quad since it requires both integrals (x and y). Thanks a lot for your help. Mo
0 comentarios
Respuesta aceptada
Mike Hosea
el 7 de Ag. de 2012
You might try to do it symbolically with INT. Numerically, you could do this:
fx = @(t)arrayfun(@(x)integral(@(y)f(x,y),-inf,inf),t)
Naturally you would use whatever the correct range is on y if it's not -inf to inf. I just wrapped it with arrayfun so you could easily integrate it or plot it. I also used arrayfun because you can substitute quadgk for integral if you don't have R2012a. With the new integral function in particular you also have the option of using 'ArrayValued' option. Here's an example
BivariateNormalPDF = @(x,y,mux,sigmax,muy,sigmay,rho) ...
exp(-(((x-mux)/sigmax).^2 ...
+ ((y-muy)/sigmay).^2 ...
- 2*rho*((x-mux).*(y-muy)/(sigmax*sigmay)) ...
)/(2*(1-rho*rho)) ...
)/(2*pi*sigmax*sigmay*sqrt(1-rho*rho));
f = @(x,y)BivariateNormalPDF(x,y,3,1,1,2,0.5);
fx = @(x)integral(@(y)f(x,y),-inf,inf,'ArrayValued',true);
You can now plot or integrate fx.
>> x = -2:0.1:8;
>> plot(x,fx(x));
>> integral(fx,-inf,inf)
ans =
1
-- Mike
5 comentarios
Antonio Marino
el 19 de Nov. de 2020
Hi Mike, I would like to ask you if the same procedure is suitable to calculate the conditional distribution dividing the joint and marginal.
If it is possible Can you explain how?
Would be very useful to me for my thesis.
thank you in advance.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!