Is there some softaware that deals with random variables as objects?
For example, suppose I define some i.i.d. random variables $X_1,\ldots, X_n\in N(0,1)$, where $N(0,1)$ is the normal distribution with mean 0 and variance 1. After that, I could want to calculates something like $$E\Big(\sum_{i,j=1}^nX_iX_j,\Big)$$
In this particular case, I know that $E\Big(\sum_{i,j=1}^nX_iX_j,\Big) = E\Big(\sum_{i=1}^n X_i^2\Big) = \sum_{i=1}^n E(X_i^2) = n$. For more complicated expressions (with others distributions) could happen to be more moments, in this case the program just let the terms uncalculated. Or maybe, if random variables are objects, could be a way to define higher moments.
Anyone knows some software that does this?
Thank you.
PS: Its supposed to be a software that works in a symbolic way, I dont want numeric approximations.
OP wrote:
While that is correct for the special case of the N(0,1) in your example, some care should be taken by the passing reader to note that it is not generally correct, because $E[X Y] \ne E[X^2]$ (even if $X$ and $Y$ are independent). A more general valid expression would be:
$$E\Big(\sum_{i,j=1}^n X_i X_j\Big) = E\Big [\Big (\sum_{i=1}^n X_i\Big)^2\Big ] $$
To answer your question re software: the mathStatica software package for Mathematica provides a suite of specialised moment of moment functions that provide exactly this functionality (I am one of the authors).
For examples, see Chapter 7 of our book:
A free download of the chapter is available here:
http://www.mathstatica.com/book/Rose_and_Smith_2002edition_Chapter7.pdf