Borrar filtros
Borrar filtros

Symbolic computation of expected values E(x)

34 visualizaciones (últimos 30 días)
Juan Ignacio Peña
Juan Ignacio Peña el 4 de Feb. de 2018
Comentada: John D'Errico el 7 de Jul. de 2019
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?

Respuestas (2)

Alok Nimrani
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
Juan Ignacio Peña
Juan Ignacio Peña el 15 de Feb. de 2018
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 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

Iniciar sesión para comentar.


Juan Ignacio Peña
Juan Ignacio Peña el 16 de Feb. de 2018
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 comentarios
Daniel Rutherford
Daniel Rutherford el 6 de Jul. de 2019
that's a bummer. Work on this matlab
John D'Errico
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.

Iniciar sesión para comentar.

Categorías

Más información sobre MuPAD en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by