1
$\begingroup$
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.

$\endgroup$
7
  • $\begingroup$ Just who is "Lacplac"? $\endgroup$
    – J. M.'s torpor
    May 7 '13 at 4:08
  • 2
    $\begingroup$ @J.M. A friend of mine gador.com.ar/?cont=prod&id=552 $\endgroup$ May 7 '13 at 4:12
  • $\begingroup$ @bel, your friend makes me sleepy. $\endgroup$
    – J. M.'s torpor
    May 7 '13 at 4:14
  • $\begingroup$ @J.M. Sorry to spoil the joke with my edit, but I felt I had a duty to posterity. $\endgroup$
    – m_goldberg
    May 7 '13 at 4:18
  • $\begingroup$ @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.) $\endgroup$
    – J. M.'s torpor
    May 7 '13 at 4:21
2
$\begingroup$
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.
$\endgroup$
2
  • $\begingroup$ Complex Integral.. Anyway I don't see any reason to use ":=" instead of "=" in this case. "=" works fine. $\endgroup$
    – user6932
    May 7 '13 at 6:14
  • 1
    $\begingroup$ @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. $\endgroup$
    – m_goldberg
    May 7 '13 at 22:38
0
$\begingroup$

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
*)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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