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 2023/12/12 11:18:39 UTC

(commons-statistics) 01/04: Remove local variable

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 b175b0daf5ea13ba78f52625a4ed03f4ab0b8d62
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Mon Dec 11 23:12:45 2023 +0000

    Remove local variable
---
 .../apache/commons/statistics/descriptive/SumOfSquaredDeviations.java  | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfSquaredDeviations.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfSquaredDeviations.java
index 150c351..2e574f6 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfSquaredDeviations.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfSquaredDeviations.java
@@ -112,7 +112,6 @@ class SumOfSquaredDeviations extends FirstMoment {
             s += dx;
             ss += dx * dx;
         }
-        final long n = values.length;
         // The sum of squared deviations is ss - (s * s / n).
         // The second term ideally should be zero; in practice it is a good approximation
         // of the error in the first term.
@@ -120,7 +119,7 @@ class SumOfSquaredDeviations extends FirstMoment {
         // when ss is infinite, assign it an infinite value which is its intended value.
         final double sumSquaredDev = ss == Double.POSITIVE_INFINITY ?
             Double.POSITIVE_INFINITY :
-            ss - (s * s / n);
+            ss - (s * s / values.length);
         return new SumOfSquaredDeviations(sumSquaredDev, m1);
     }