2
$\begingroup$
f[p_, x_] := Piecewise[{{p*Exp[-x], 0 < x}, {(1 - p)*Exp[x], x < 0}}, 0];
auxmu[p_, d_] := x^d Piecewise[{{p*Exp[-x], 0 < x}, {(1 - p)*Exp[x], x < 0}}, 0];
val1 = Integrate[auxmu[p, 1], {x, -Infinity, Infinity}]

mu[p_, d_] := Integrate[x^d f[p, x], {x, -Infinity, Infinity}]

I get error when defining the last sentence.

Thanks.

$\endgroup$

1 Answer 1

4
$\begingroup$

You probably need conditions on d:

f[p_, x_] := Piecewise[{{p*Exp[-x], 0 < x}, {(1 - p) Exp[x], x < 0}}, 0]; 
Integrate[x^d f[p, x], {x, -Infinity, Infinity}, Assumptions -> d > -1]

seems to work fine.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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