Symbolic computation of expected values E(x)
44 次查看(过去 30 天)
显示 更早的评论
Assume x and y are two symbolic variables (random variables) and I want to calculate the expectation of their sum: E(x+y)= E(x) + E(y) or their product E(x * y) or the covariance COVAR(x,y) = E(x*y) - E(x)*E(y). Is there any way of doing this with the Symbolic Math toolbox?
0 个评论
回答(2 个)
Alok Nimrani
2018-2-15
Hi Juan,
You can try using the MuPAD language included in Symbolic Math Toolbox, which is optimized for handling and operating on symbolic math expressions.
To calculate the expected value i.e. mean of a random variable, you can check the stats::mean MuPAD function: https://www.mathworks.com/help/symbolic/mupad_ref/stats-mean.html
And to calculate the covariance between two random variables, you can check the stats::covariance function: https://www.mathworks.com/help/symbolic/mupad_ref/stats-covariance.html
Hope this helps.
Thanks
2 个评论
Alok Nimrani
2018-2-16
Hi Juan,
I am unable to understand your use case. Could you please elaborate your use case with some example and exactly what you are looking for?
Thanks
Juan Ignacio Peña
2018-2-16
3 个评论
John D'Errico
2019-7-7
First, please stop adding answers to make a comment.
"Work on it?"
But why? For example, most of the classical distributions have simple formulas for the mean and variance, etc. You can just look them up. (Look on wikipedia, for example.) In fact, you are the first person who I have ever seen asking for this.
Are you asking for something basic? That is, do you just want MATLAB to parrot back simplistic formulas?
E(x+y) = E(x) + E(y)
var(x+y) = var(x) + var(y) + 2*cov(x,y)
I think that is not what you are asking.
It seems like you effectively want MATLAB to have a new class of symbolic variable, one that describes a random variable, where it understands the variable actually comprises a distribution. So, you want MATLAB to know that X is for example, actually a Normal or a Gamma random variable, and be able to do symbolic computations on it? Sorry. That would take an entirely new toolbox, or at least a moderately significant addition to the existing one.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!