Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.
f2[x_, mu2_, sigma2_] =  1/Sqrt[2*sigma2^2]*Exp[-Sqrt[2]*Abs[(x - mu2)/sigma2]]

Integrate[x*f2[x, mu, sigma], {x, -Infinity, Infinity},  Assumptions -> sigma > 0]

I am pretty sure that the above should produce mu, but it doesn't. What's wrong with it? I did the same thing in Sage, and it worked all right.

share|improve this question
    
Just who is "Lacplac"? –  J. M. May 7 '13 at 4:08
2  
@J.M. A friend of mine gador.com.ar/?cont=prod&id=552 –  belisarius May 7 '13 at 4:12
    
@bel, your friend makes me sleepy. –  J. M. May 7 '13 at 4:14
    
@J.M. Sorry to spoil the joke with my edit, but I felt I had a duty to posterity. –  m_goldberg May 7 '13 at 4:18
    
@m_goldberg, no worries, and thanks. :) (Actually, I was hoping the OP himself might give an introduction to whoever The Great Mister Lacplac was, but oh well.) –  J. M. May 7 '13 at 4:21
show 2 more comments

2 Answers

up vote 2 down vote accepted
f2[x_, mu2_, sigma2_] := 1/Sqrt[2*sigma2^2]*Exp[-Sqrt[2]*Abs[(x - mu2)/sigma2]]

Integrate[x*f2[x, mu, h], {x, -Infinity, Infinity},
          Assumptions -> {Element[mu, Reals], h > 0}]

(*
  mu
*)

Edit

Let's make what he did wrong crystal clear to the OP.

  1. Should have used SetDelayed (:=) rather than Set (=) when defining f2.
  2. Needed to have an additional assumption that mu was a real number.
share|improve this answer
    
Complex Integral.. Anyway I don't see any reason to use ":=" instead of "=" in this case. "=" works fine. –  user6932 May 7 '13 at 6:14
1  
@user6932. That's only because you haven't so far made any global assignments to x, mu1 or sigma2. But you have a time bomb ticking away. –  m_goldberg May 7 '13 at 22:38
add comment

One way to circumvent it is like this

f2[x_, mu2_, sigma2_] :=  
                    Piecewise[{{1/Sqrt[2*sigma2^2]*Exp[-Sqrt[2]*((x - mu2)/sigma2)], x - mu2 >= 0}, 
                               {1/Sqrt[2*sigma2^2]*Exp[-Sqrt[2]*((mu2 - x)/sigma2)], x - mu2 < 0}}]

Integrate[x*f2[x, mu, sigma], {x, -Infinity, Infinity},  Assumptions -> sigma > 0]

(*
  mu
*)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.