Skip to content

Commit b7941ab

Browse files
authored
Corrected quadratic mean
1 parent 255ab52 commit b7941ab

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/com/thealgorithms/maths/Means.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ public static Double harmonic(final Iterable<Double> numbers) {
109109

110110
public static Double quadratic(final Iterable<Double> numbers) {
111111
checkIfNotEmpty(numbers);
112-
double sum = StreamSupport.stream(numbers.spliterator(), false).reduce(0d, (x, y) -> x * x + y * y);
112+
double sumOfSquares = StreamSupport.stream(numbers.spliterator(), false).reduce(0d, (x, y) -> x + y * y);
113113
int size = IterableUtils.size(numbers);
114-
return Math.sqrt(sum / size);
114+
return Math.sqrt(sumOfSquares / size);
115115
}
116116

117117
/**

0 commit comments

Comments
 (0)