1
$\begingroup$

The PDF applied to EmpiricalDistribution of a set of real plots as zero. Given:

points = {0.360656, 0.459016, 0.557377, 0.540984, 0.786885, 0.42623, 0.344262, 0.57377, 0.42623, 0.459016};

Then:

points // EmpiricalDistribution // 
 Query[{Plot[CDF[#, x], {x, 0, 1}] & , Plot[PDF[#, x], {x, 0, 1}] &}]

enter image description here

Whereas for example HistogramDistribution works:

points // HistogramDistribution // 
 Query[{Plot[CDF[#, x], {x, 0, 1}] & , Plot[PDF[#, x], {x, 0, 1}] &}]

enter image description here

Known issue or expected behavior due to the discrete set of points? I've also tried with ~10k points with the same result. One would expect delta spikes located at the input points.

$\endgroup$
5
$\begingroup$

I don't find it a bug. Let us go into deep:

points = {0.360656, 0.459016, 0.557377, 0.540984, 0.786885, 0.42623,0.344262, 0.57377,
 0.42623, 0.459016};
pdf = PDF[EmpiricalDistribution[points], x]

0.1 Boole[0.344262 == x] + 0.1 Boole[0.360656 == x] + 0.2 Boole[0.42623 == x] + 0.2 Boole[0.459016 == x] + 0.1 Boole[0.540984 == x] + 0.1 Boole[0.557377 == x] + 0.1 Boole[0.57377 == x] + 0.1 Boole[0.786885 == x]

In order to draw it, DiscretePlot instead of Plot should be used.

DiscretePlot[pdf, {x, points}]

enter image description here

$\endgroup$
  • $\begingroup$ With Frame -> True, PlotRange -> {{Min@points, Max@points}, {0, 0.2}}, PlotRangePadding -> 0.05, the plot is much more informative. $\endgroup$ – corey979 May 12 '18 at 21:44

Your Answer

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

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