# CDF looks OK but Integral of PDF does not sum to 1.0

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:

Clear["Global*"];
(*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?

• 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. Mar 3 '20 at 16:59
• @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... Mar 3 '20 at 17:08
• @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? Mar 3 '20 at 17:22
• 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`. Mar 3 '20 at 19:57
• The correct solution depends on what you want to do with this distribution. Mar 3 '20 at 19:58