calcuating expected value from a joint distribution
Show older comments
Hi Everyone,
I am really struggling with this problem so i really hope someone can help me out.
My problem is as follows: I have random variables I will call xand y, and for which I have a joint pdf f(x,y). My question is: how can I compute the expected value of x/y, that is:
E(x/y)=DoubleIntegral(x/y*f(x,y)dx dy)???
i tried to use dblquad to do the integral using mvnpdf to generate a normal joint distribution of X and Y as a trial but i get errors and i cant figure out a way to go...any help wld be greatly appreciated, Thanks!
Answers (1)
Tom Lane
on 1 Mar 2013
You don't say what errors you get.
You could get problems if you are in a region where y is near zero. Away from that region, here's an example where I compute the mean of a sample from the distribution, then verify it is close to the value I get by integrating over a finite but large region:
>> mu = [10 10];
>> sigma = [1 1;1 2];
>> xy = mvnrnd(mu,sigma,1000);
>> mean(xy(:,1)./xy(:,2))
ans =
1.0103
>> dblquad(@(x,y)(x(:)./y).*mvnpdf([x(:) repmat(y,numel(x),1)],mu,sigma),1,20,1,20)
ans =
1.0107
Categories
Find more on Uniform Distribution (Continuous) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!