Message Boards Message Boards

0
|
5901 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Specify a general rule, so that mathematica always evaluate it?

Posted 6 years ago

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

POSTED BY: uwe moehring
2 Replies
Posted 6 years ago

Thank you, Neil.

My first trials with your recommended moveconst-function worked very well.

Regards Uwe

POSTED BY: uwe moehring
POSTED BY: Neil Singer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract