필터 지우기
필터 지우기

Symbolic computation of expected values E(x)

조회 수: 34 (최근 30일)
Juan Ignacio Peña
Juan Ignacio Peña 2018년 2월 4일
댓글: John D'Errico 2019년 7월 7일
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
Daniel Rutherford
Daniel Rutherford 2019년 7월 6일
that's a bummer. Work on this matlab
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