I want to specify a set of some general mathematical rules regarding probability theory to solve equations with "expectation" and "variance" for random variables. Therefore I want to "teach" mathematica to evaluate the expression
Integrate[p[x], {x, -Infinity, Infinity}] -> 1
always to "1". p[x] should be any arbitrary "Probability Density Function" of "x" with the result, whenever mathematica's evaluation finds the integral in an expression, it should replace it by "1" I tried this with
Simplify[Integrate[p[x], {x, -Infinity, Infinity}] /. Integrate[p[x], {x, -Infinity, Infinity}] :> 1]
and similar expressions and rules, but when I put into the next cell:
Integrate[p[x], {x, -Infinity, Infinity}]
the output is always the Integral itself, but not the expected value of "1".
My final goal is if I specify:
expectation[x_] := Integrate[x*p[x], {x, -Infinity, Infinity}]
expectation[z_] := Integrate[z*p[x], {x, -Infinity, Infinity}] /; FreeQ[z, x] := z /; FreeQ[z, x]
that mathematica recognize "z" as a constant, independant from x, get it out of the Integral and evaluates the remaining Integral to "1" and the final result as "z"
How can I solve such a problem ? Thank you for your support.
Regards Uwe