Skip to content

Commit

Permalink
Fix Hipparchus-Math#316 EmpiricalDistribution#density() shouldn't ret…
Browse files Browse the repository at this point in the history
…urn NaN

see discussion in Hipparchus-Math#315
  • Loading branch information
axkr committed Mar 6, 2024
1 parent a8fe2cf commit 57f8f3f
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,11 @@ public double density(double x) {
}
final int binIndex = findBin(x);
final RealDistribution kernel = getKernel(binStats.get(binIndex));
return kernel.density(x) * pB(binIndex) / kB(binIndex);
double kernelDensity = kernel.density(x);
if (kernelDensity == 0d) {
return 0d;
}
return kernelDensity * pB(binIndex) / kB(binIndex);
}

/**
Expand Down

0 comments on commit 57f8f3f

Please sign in to comment.