You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2020/06/23 17:00:51 UTC
[commons-statistics] 24/35: LogNormalDistribution: remove
impossible condition
This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-statistics.git
commit dc30ade59f7f65ad210a30295ace6887cddbfa07
Author: aherbert <ah...@apache.org>
AuthorDate: Tue Jun 23 16:21:31 2020 +0100
LogNormalDistribution: remove impossible condition
If x0 is not larger than x1, and x0 is larger than zero, then x1 cannot
be zero or below. Thus this condition:
if (x0 <= 0 || x1 <= 0)
can only be true in the second part if x0 is NaN. NaN checking is not
supported so we can drop the second condition.
---
.../apache/commons/statistics/distribution/LogNormalDistribution.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/LogNormalDistribution.java b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/LogNormalDistribution.java
index 0fbe7bd..cb05e5e 100644
--- a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/LogNormalDistribution.java
+++ b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/LogNormalDistribution.java
@@ -162,9 +162,10 @@ public class LogNormalDistribution extends AbstractContinuousDistribution {
throw new DistributionException(DistributionException.TOO_LARGE,
x0, x1);
}
- if (x0 <= 0 || x1 <= 0) {
+ if (x0 <= 0) {
return super.probability(x0, x1);
}
+ // Assumes x1 >= x0 && x0 > 0
final double denom = shape * SQRT2;
final double v0 = (Math.log(x0) - scale) / denom;
final double v1 = (Math.log(x1) - scale) / denom;