Ask Your Question
0

simplifying an expectation with the normal law

asked 2020-11-29 12:13:42 +0100

Cyrille gravatar image

Just for the fun (since I can find the good result), why am I obliged to help so much Sagemath toç gpo through the last steps of this integration for so elementary evidence ?

var("a x s m")
f(x) = - exp(- a*x)
p(x) = (1/ (sqrt(2*pi)*s))*exp(- (1/2)*((x-m)/s)^2)
g(x) = f(x)*p(x)
show((integrate(g(x),(x,-oo,oo)).full_simplify()))
show(integrate(g(x),(x,-oo,oo)).full_simplify().subs({sqrt(s^2):s}).subs({sqrt(s^2):s}))
edit retag flag offensive close merge delete

Comments

Typo: "toç gpo" -> "to go".

slelievre gravatar imageslelievre ( 2020-11-29 15:45:44 +0100 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2020-11-29 13:18:14 +0100

Emmanuel Charpentier gravatar image

Is this :

sage: integrate(g(x),(x,-oo,oo)).full_simplify().canonicalize_radical()         
-e^(1/2*a^2*s^2 - a*m)

what you want ?

BTW :

sage: assume (a, m, x, "real")                                                  
sage: assume(s>0)                                                               
sage: assumptions()                                                             
[a is real, m is real, x is real, s > 0]
sage: integrate(g(x),(x,-oo,oo)).full_simplify()                                
-e^(1/2*a^2*s^2 - a*m)
sage: integrate(g(x),(x,-oo,oo)).simplify()                                     
-e^(1/2*a^2*s^2 - a*m)

In integration, assumptions may be capital...

edit flag offensive delete link more

Comments

yes thanks

Cyrille gravatar imageCyrille ( 2020-11-29 13:23:03 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-11-29 12:13:42 +0100

Seen: 155 times

Last updated: Nov 29 '20