Message Boards Message Boards

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

Simplify expectation/integral over PDF

Posted 4 years ago

Integrating over x on a Normal-PDF, I expect the answer to simplify to mu. However, this does not seems to work:

FullSimplify[Integrate[(1/(s*Sqrt[2*Pi]))*exp[-0.5*(((x-m)/s)^2)], x],  s \[Element] Reals \[And]s>0\[And]x\[Element] Reals\[And] m \[Element] Reals]

What am I forgetting?

(for convenience: mu is abbreviated m, sigma is abbreviated s)

POSTED BY: Nino Hardt
3 Replies

Try:

FullSimplify[
 Integrate[(1/(s*Sqrt[2*Pi]))*Exp[-1/2*(((x - m)/s)^2)], x], 
 s \[Element] Reals \[And] s > 0 \[And] x \[Element] Reals \[And] 
  m \[Element] Reals]

(*-(1/2) Erf[(m - x)/(Sqrt[2] s)]*)

Integrate[(1/(s*Sqrt[2*Pi]))*Exp[-1/2*(((x - m)/s)^2)], {x, -Infinity, Infinity}, Assumptions -> {s > 0, m > 0}]
(* 1 *)

Integrate[(1/(s*Sqrt[2*Pi]))*Exp[-1/2*(((x - m)/s)^2)], {x, 0, Infinity}, Assumptions -> {s > 0, m > 0}]
 (*1/2 (1 + Erf[m/(Sqrt[2] s)])*)
POSTED BY: Mariusz Iwaniuk
Posted 4 years ago

Capital E on exp, of course. Ouch. Thank you. Also: How 0.5 vs 1/2 results in different output.

So this returns mu:

FullSimplify[
Integrate[x*(1/(s*Sqrt[2*Pi]))*Exp[-1/2*(((x-m)/s)^2)], {x, -Infinity, Infinity}],  
s \[Element] Reals \[And]s>0\[And]x\[Element] Reals\[And] 
m \[Element] Reals]
POSTED BY: Nino Hardt

Looks different, but answer is the same.

Try:

Integrate[
 x*(1/(s*Sqrt[2*Pi]))*Exp[-0.5*(((x - m)/s)^2)], {x, -Infinity, 
  Infinity}, Assumptions -> {s > 0, m > 0}]
f[m_] := m; Table[
Plot[{Evaluate[INT] // Re, f[m]}, {m, 0.01, 10}, 
PlotStyle -> {Black, {Dashed, Red}}, 
PlotLegends -> {"integral with 0.5 not 1/2", "f[m]"}], {s, 1, 10, 1/2}]

(*s from: 1 to 10 and m from: 0.01 to 10*)
POSTED BY: Mariusz Iwaniuk
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