Symbolic computation of expected values E(x)
44 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Alok Nimrani
el 15 de Feb. de 2018
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 comentarios
Alok Nimrani
el 16 de Feb. de 2018
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
el 16 de Feb. de 2018
3 comentarios
John D'Errico
el 7 de Jul. de 2019
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.
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!