1
$\begingroup$

I'm trying to solve the following integral:

$$\int_{-\infty}^{\mu_1}\exp\{-\rho_{\tau_1}(y-\mu_1)-\rho_{\tau_2}(y-\mu_2)\}\mathbb{I}_{\tau_1<\tau_2}\mathbb{I}_{\mu_1<\mu_2}\,dy$$ without much success. Here $\rho_\tau(u) = \tau u + (\tau-1)u\mathbb{I}_{u<0}$ is the quantile function (see Wiki here), $(\mu_1, \mu_2)\in R^2$, with and $(\tau_1, \tau_2)\in (0,1)^2.$

I've tried with this:

Integrate[
 Exp[-(tau1*(y - mu1)*If[y - mu1 >= 0, 1, 0] + (tau1-1)*(y - mu1)*
       If[y - mu1 < 0, 1, 0])]*
  Exp[-(tau2*(y - mu2)*If[y - mu2 >= 0, 1, 0] + (tau2-1)*(y - mu2)*
       If[y - mu2 < 0, 1, 0])], {y, -Infinity, mu1}, Assumptions -> {tau1 < tau2}]

but the output I get is the input its self. Any idea about how to fix it?

Edit: the answer is obviously

$$\frac{e^{(2-\tau_1-\tau_2)\mu_1-\bar\mu}}{2-\tau_1-\tau_2}\,,$$ where $\bar\mu = (1-\tau_1)\mu_1+(1-\tau_2)\mu_2.$

$\endgroup$
3
  • 2
    $\begingroup$ Try defining the function using Piecewise instead, perhaps. $\endgroup$
    – march
    Sep 28, 2017 at 22:17
  • 1
    $\begingroup$ Plots of your integrand (using random values for your taus and mus since none were provided) look pretty explosive for negative values of y. Do you have any reason for supposing that the integral exists? Are there tighter bounds you can put on your parameters? $\endgroup$ Sep 29, 2017 at 11:31
  • $\begingroup$ @march tried with "Picewise" and "UitStep" but neither worked. aardvark2012 you are right, there are typos in my Mathematica code and in the definition of the quantile function. Now it must be ok. I can solve it analytically obviously, as such integral is really trivial, but I find it strange that Mathematica is not able to find the solution... $\endgroup$
    – utobi
    Sep 29, 2017 at 15:14

3 Answers 3

2
$\begingroup$

You need to include the assumption that mu1 < mu2. Also use Boole rather than If

int = Assuming[{tau1 < tau2, mu1 < mu2},
  Integrate[
    Exp[-(tau1*(y - mu1)*Boole[y - mu1 >= 0] + (tau1 - 1)*(y - mu1)*
          Boole[y - mu1 < 0])]*
     Exp[-(tau2*(y - mu2)*Boole[y - mu2 >= 0] + (tau2 - 1)*(y - mu2)*
          Boole[y - mu2 < 0])], {y, -Infinity, mu1}] // Simplify]

(* ConditionalExpression[-(E^(-(mu1 - mu2) (-1 + tau2))/(-2 + tau1 + tau2)), 
 tau1 + tau2 < 2] *)

Comparing to expected result

(int // Normal) == 
  Exp[(2 - tau1 - tau2) mu1 - ((1 - tau1) mu1 + (1 - tau2) mu2)]/
   (2 - tau1 - tau2) // Simplify

(* True *)
$\endgroup$
1
  • $\begingroup$ The use of Boole[] is not required in V13. (It probably was in 2018, but I can't check when the handling of If[] was made more robust.) $\endgroup$
    – Michael E2
    Sep 11, 2022 at 12:54
2
$\begingroup$

Use PiecewiseExpand on the integrand and include all the assumptions:

Integrate[
 Exp[-(tau1*(y - mu1)*If[y - mu1 >= 0, 1, 0] + (tau1 - 1)*(y - mu1)*
        If[y - mu1 < 0, 1, 0])]*
   Exp[-(tau2*(y - mu2)*If[y - mu2 >= 0, 1, 0] + (tau2 - 1)*(y - mu2)*
        If[y - mu2 < 0, 1, 0])] //
  PiecewiseExpand,
 {y, -Infinity, mu1},
 Assumptions -> {0 < tau1 < tau2 < 1, mu1 < mu2}]  (* N.B. *)
(*  -(E^(-(mu1 - mu2) (-1 + tau2))/(-2 + tau1 + tau2))  *)

(* OP's form of the answer *)
mubar = (1 - tau1) mu1 + (1 - tau2) mu2;
Exp[(2 - tau1 - tau2) mu1 - mubar]/(2 - tau1 - tau2) // Simplify
(*  -(E^(-(mu1 - mu2) (-1 + tau2))/(-2 + tau1 + tau2))  *)
$\endgroup$
1
$\begingroup$

I defined the quantile function using HeavisideTheta as

rho[u_, tau_] := tau u + (1 - tau) u HeavisideTheta[-u];

When I tried to integrate your expression using this definition, I was informed that the integral diverges. I tried the expression below instead

Integrate[
Exp[rho[(y - mu1), tau1] + rho[(y - mu2), tau2]] HeavisideTheta[
tau2 - tau1], {y, -Infinity, mu1}]

and got as result

HeavisideTheta[tau2 - tau1]E^(mu1 - mu2)/2

when mu1 <= mu2 and

HeavisideTheta[tau2 - tau1]E^((mu1 - mu2) tau2)/(1 + tau2)

otherwise.

$\endgroup$
1
  • $\begingroup$ Thanks for your effort. There was a typo in my definition of the quantile function...sorry for that. So, obviously, your answer is incorrect. $\endgroup$
    – utobi
    Sep 29, 2017 at 15:17

Your Answer

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

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