Symbolic computation of expected values E(x)

34 次查看(过去 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?

回答(2 个)

Alok Nimrani
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 个评论
Juan Ignacio Peña
Juan Ignacio Peña 2018-2-15
Thank you Alok. But what I want to do is simbolic (not numerical) manipulation. I'm looking for functions 'E' , 'VAR' and 'COV' producing symbolic results. For instance E(x+y)=E(x) + E(y), COV(x,y) = E(x*y) - E(x)*E(y), and so on.
Alok Nimrani
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
Juan Ignacio Peña 2018-2-16
Hi Alok, thank you for your response. Let x and y be two independent random variables following Normal distributions N(m_x, s_x) and N(m_y, s_y). I'm looking for a procedure in MATLAB allowing for symbolic manipulation with these variables. I would need a function (let's call it EXPECTATION, meaning average value) that when applied to x yields m_x, i.e if you write "EXPECTATION(x)" yo should get "m_x" or if you write "EXPECTATION(x*y)" you should get "m_x*m_y" and so on. Other useful functions would be VARIANCE, COVARIANCE, etc.
  3 个评论
John D'Errico
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MuPAD 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by