I defined a CDF as a function of another CDF of a well known probabilistic distribution. Now I want to obtain the PDF of the former CDF. To check if the PDF is correct I integrate it over the range and see if I got a value equal to 1.0. I don't. The CDF looks OK, tends to zero when the value approaches -Infinitty and tends to one as the value approaches +Infinity. Here is the code:

(*Initial Input data*)
u11 = 1;
s11 = u11*1;
p1 = 0.1;
(*Initial CDF*)
 FS11[r_] := CDF[NormalDistribution[u11, s11], r]
(*Modified CDF*)
FS1[x_] := (1 - p1)*HeavisideTheta[x] + p1*FS11[x]

Plotting FS1I see no errors:

Plot[FS1[x], {x, -4, 4}, AspectRatio -> 0.2, PlotRange -> Full]

However when I obtain the PDF

fS10[x_?NumericQ] = D[FS1[x], x]

and integrate it I get a value different that 1.0

NIntegrate[fS10[y], {y, -Infinity, +Infinity}]

What am I missing here?

  • 3
    $\begingroup$ What do you expect? Your CDF has a jump and then you try to define the PDF by numerical differentiation, That's just not going to work; there's no way to represent the delta spike you get from differentiation a unit step numerically. If you use HeavisideTheta, then symbolic differentiation gives you the DiracDelta you need. Or use ProbabilityDistribution[{"CDF",cdf},...] to define a distribution in terms of its CDF. $\endgroup$ – Sjoerd Smit Mar 3 '20 at 16:59
  • $\begingroup$ @SjoerdSmit but even if I change UniStep for HeavisideThetaI get the same result or if I define fS10[x_] := (1 - p1)*DiracDelta[x] + p1*fS11[x] and fS11[r_] := PDF[NormalDistribution[u11, s11], r] when I NIntegrate[fS10[y], {y, -Infinity, +Infinity}] I get 0.1... $\endgroup$ – jpcgandre Mar 3 '20 at 17:08
  • $\begingroup$ @SjoerdSmit regarding your second suggestion can you elaborate that please? Something like FS1n[x_] = ProbabilityDistribution[{"CDF", FS1[x]},...] and then how to obtain the PDF? $\endgroup$ – jpcgandre Mar 3 '20 at 17:22
  • 1
    $\begingroup$ It doesn't matter whether you use UnitStep or HeavisideTheta. The point is that a Dirac delta cannot be handled numerically. When treated numerically, DiractDelta[x] is as good as 0. $\endgroup$ – Szabolcs Mar 3 '20 at 19:57
  • 1
    $\begingroup$ The correct solution depends on what you want to do with this distribution. $\endgroup$ – Szabolcs Mar 3 '20 at 19:58

Your Answer

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

Browse other questions tagged or ask your own question.