Skip to content

Commit

Permalink
Merge pull request #317 from axkr/master
Browse files Browse the repository at this point in the history
Fix #316 EmpiricalDistribution#density() shouldn't return NaN
  • Loading branch information
maisonobe authored Mar 14, 2024
2 parents 783d3d9 + 57f8f3f commit 6a43f85
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 6a43f85

Please sign in to comment.