I have an expression that consists of a large sum of variables of powers like:
X[1]^(2p) X[2]^2 + X[1]^2 X[2]^(2p) + X1[1]^(1+p) X[2]^(1+p) ...
Now I would like to replace X[k]^p
with sigma^p (p-1)!!
.
While I can use the list index as a variable I cannot use the exponent as variable. For example, I cannot use
expr /. X[k_]^(l_) -> sigma^l (l-1)!!
Instead I have to list all options manually:
expr /. X[k_]^2 X[l_]^(2p) -> sigma^(2+2p) (2p-1)!! /. X[k_]^(p+1) X[l_]^(p+1) -> sigma^(2+2p) p!! p!!
Why is this and how can I implement this?
expr
, then usingExpectation[expr, {X[1] \[Distributed] NormalDistribution[\[Mu], \[Sigma]], X[2] \[Distributed] NormalDistribution[\[Mu], \[Sigma]]}]
will avoid the necessity of complex substitution rules. $\endgroup$