# Differentiating a Cumulative Distribution Function which has a discontinuity at $0$

I want to take the derivative of a distribution function which has a discontinuity at $0$. Here is the function:

temp0[x_] :=If[Element[x, Reals], Sqrt[Pi]*(Erfc[(-2 + Log[2])/(2*Sqrt[2])] + (1 + Erf[(1 +Piecewise[{{(x - Log[2])/2, x < 0}}, (x + Log[2])/2])/Sqrt[2]] - Erfc[(-2 + Log[2])/(2*Sqrt[2])])*UnitStep[-Log[2]/2 - Piecewise[{{(x - Log[2])/2, x < 0}}, (x + Log[2])/2]]) + Sqrt[(2*Pi)/E]*(Erf[Log[2]/(2*Sqrt[2])] - Erf[Piecewise[{{(x - Log[2])/2, x < 0}}, (x + Log[2])/2]/Sqrt[2]])*UnitStep[-Log[2]/2 + Piecewise[{{(x - Log[2])/2, x < 0}}, (x + Log[2])/2]] + 2*Sqrt[Pi]*(-Erf[(2 + Log[2])/(2*Sqrt[2])] + Erf[(1 + Piecewise[{{(x - Log[2])/2, x < 0}}, (x + Log[2])/2])/Sqrt[2]])*UnitStep[-Log[2]/2 + Piecewise[{{(x - Log[2])/2, x < 0}}, (x + Log[2])/2]] + Sqrt[(2*Pi)/E]*(Erf[Log[2]/(2*Sqrt[2])] + Erf[Piecewise[{{(x - Log[2])/2, x < 0}}, (x + Log[2])/2]/Sqrt[2]])*UnitStep[Log[2]/2 + Piecewise[{{(x - Log[2])/2, x < 0}}, (x + Log[2])/2]], Integrate[(Sqrt[2]*UnitStep[-y - Log[2]/2] + 2*((Sqrt[2] - E^y)*UnitStep[y - Log[2]/2] + E^y*UnitStep[y + Log[2]/2]))/E^((1 + y)^2/2), {y, -Infinity, Piecewise[{{(x - Log[2])/2, x < 0}, {(x + Log[2])/2, x >= 0}}, 0]}, Assumptions -> NotElement[x, Reals]]]/(Sqrt[Pi]*(2*Sqrt[2/E]*Erf[Log[2]/(2*Sqrt[2])] + Erfc[(-2 + Log[2])/(2*Sqrt[2])] + 2*Erfc[(2 + Log[2])/(2*Sqrt[2])]))


If I plot it I get

The result of the derivation should be a density function. I used

fx0[x_] := D[temp0[x], x]


to get the density function but it didnt help me. Do you know how can I ignore the discontinuity at $0$ for the derivation?

Thank you very much.

-

Using the definition of temp0[x], it is possible to plot the derivative by taking the limit:

der[x_] := Limit[temp0'[x + eps], eps -> 0];
Plot[der[x], {x, -5, 5}]


Note the kink at the origin. This uses a similar technique to J. M.'s answer here.

-

OP wrote: Do you know how can I ignore the discontinuity at 0 for the derivation?

You most definitely do not want to 'ignore' the discontinuity at 0. The fact that the CDF jumps from about 0.64 to about 0.84 at $x = 0$ implies that your density is:

• piecewise continuous for $x < 0$,

• has a discrete mass at $x = 0$, i.e. $f(0) \approx 0.2$, and then

• piecewise continuous for $x>0$.

The density should thus appear like so:

You can plot the discrete mass at $x = 0$ using something like:

BB = ListPlot[{{0, .2}}, PlotStyle -> AbsolutePointSize[8], Filling -> Axis]

and then:

Show[AA,BB]


where AA is the continuous plot ... to get the complete mixed continuous/discrete density.

-
thanks for the post and for the information. You are exactly right, in fact. I get the distribution function via transformation temp0[x_] := ff0[ll[x]] here ll[x] is the inverse function of Piecewise[{{{0}, -Log[2]/2 <= x <= Log[2]/2}, {Log[E^(2*x)/2], 2*x > Log[2]}}, Log[2*E^(2*x)]] and ff0[x] is the CDF of the density (UnitStep[-x - Log[2]/2]/(E^((1 + x)^2/2)*Sqrt[2*Pi]) + (Sqrt[2/Pi]*UnitStep[x - Log[2]/2])/E^((1 + x)^2/2) + (Sqrt[E^(-(-1 + x)^2/2)]*Sqrt[E^(-(1 + x)^2/2)]*(-UnitStep[x - Log[2]/2] + UnitStep[x + Log[2]/2]))/Sqrt[Pi])/C1 I simply took ll[0]=Log[2]/2 which is originally –  Seyhmus Güngören Oct 17 '13 at 9:22
My density doesnt add upto $1$ when I ignore the point pass. How can I modify my function at $0$? –  Seyhmus Güngören Oct 17 '13 at 11:53
I have no idea whether it is appropriate for you to ignore the discrete point ... but if the mass at $x = 0$ is p, and you want to ignore the point at $x = 0$ (??), and the continuous component of your pdf is f, then f/(1-p) should be a well-defined density that integrates to unity (with the discrete point expunged). –  wolfies Oct 17 '13 at 12:02
I will ask a new question. –  Seyhmus Güngören Oct 17 '13 at 12:36