distribution of function of random variables
Show older comments
Is there a general MATLAB method to calculate the expected value of a function of random variable?
For instance, if I have 3 random variables with known Probability density functions:
X with Probability density function f1 = @(x,sigma,mu) 1./sqrt(2*pi*sigma.^2).*exp(-(x-mu).^2./(2*sigma.^2));
Y with Probability density function f2 = @(y,sigma,mu) 1./sqrt(2*pi*sigma.^2).*exp(-(y-mu).^2./(2*sigma.^2));
Z with probabilty density function f2 = @(z,sigma,mu) 1./sqrt(2*pi*sigma.^2).*exp(-(z-mu).^2./(2*sigma.^2));
f1 f2 f3 Could be any function included uniform distributions.
Now I Have a big function F(X,Y,Z)
F= @(x,y,z) sqrt(x^2+y^2)*z^2
Is there a way to compute say the expected value of F(X,Y,Z) and to plot its numerically calculated Probability density function
Something like like:
Expected_value=unknow_matlabfunction(f1,f2,f3,F)
Thanks for any ideas.
Pierre
Here are my tootbox:
MATLAB Version 9.2 (R2017a)
Curve Fitting Toolbox Version 3.5.5 (R2017a)
Database Toolbox Version 7.1 (R2017a)
Image Processing Toolbox Version 10.0 (R2017a)
MATLAB Compiler Version 6.4 (R2017a)
MATLAB Compiler SDK Version 6.3.1 (R2017a)
Neural Network Toolbox Version 10.0 (R2017a)
Signal Processing Toolbox Version 7.4 (R2017a)
Statistics and Machine Learning Toolbox Version 11.1 (R2017a)
2 Comments
Torsten
on 29 Apr 2019
Is there a general MATLAB method to calculate the expected value of a function of random variable?
No. Not even a general mathematical method.
Pierre Allain
on 29 Apr 2019
Edited: Pierre Allain
on 29 Apr 2019
Answers (1)
Jeff Miller
on 30 Apr 2019
In principle you can do this numerically for many distributions f1,f2,f3, and many functions F with the routines in Cupid at https://github.com/milleratotago/Cupid
The general approach is to build up the complex distribution step by step, which would look something like this for your example:
f1=Normal(10,1);
f2=Uniform(0,1);
f3=Beta(6,9);
f1sqr = PowerTrans(f1,2);
f2sqr = PowerTrans(f2,2);
f3sqr = PowerTrans(f3,2);
sumf1sqrf2sqr=Convolution(f1sqr,f2sqr);
sqrtsumf1sqrf2sqr=SqrtTrans(sumf1sqrf2sqr);
sqrtsumf1sqrf2sqr.UseSplineCDFOn(100);
sqrtsumf1sqrf2sqr.UseSplinePDFOn(100);
BigFun = Product(sqrtsumf1sqrf2sqr,f3sqr);
BigFun.Mean
BigFun.LowerBound
BigFun.UpperBound
BigFun.Median
BigFun.PlotDens
To increase speed, you would probably want to use spline approximations for some distributions, e.g.
sqrtsumf1sqrf2sqr.UseSplineCDFOn(100);
sqrtsumf1sqrf2sqr.UseSplinePDFOn(100);
In practice the numerical problems might be insurmountable, depending on your original f1, f2, and f3, and your F, but it might be worth a try.
Categories
Find more on Univariate Discrete Distributions 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!