Repository: TheAlgorithms/Java
File: src/main/java/com/thealgorithms/maths/Means.java (Java)

Code before:
package com.thealgorithms.maths;

import java.util.List;

/**
 * https://en.wikipedia.org/wiki/Mean
 * <p>
 * by: Punit Patel
 */
public final class Means {

    private Means() {
    }

    /**
     * Arithmetic / Pythagorean Mean = (x₁ + x₂ + ... +  xₙ) / n
     */
    public static Double arithmetic(final List<Double> numbers) {
        if (numbers.isEmpty()) throw new IllegalArgumentException("Emtpy list given for Mean computation.");

        return numbers.stream().reduce((x, y) -> x + y).get() / numbers.size();
    }

    /**
     * Geometric Mean = (x₁ · x₂ · ... · xₙ) ^ 1/n
     */
    public static Double geometric(final List<Double> numbers) {
        if (numbers.isEmpty()) throw new IllegalArgumentException("Emtpy list given for Mean computation.");

        return Math.pow(numbers.stream().reduce((x, y) -> x * y).get(), 1.0 / numbers.size());
    }

    /**
     * Harmonic Mean = n / (1/x₁ + 1/x₂ + ... +  1/xₙ)
     */
    public static double harmonic(final List<Double> numbers) {
        if (numbers.isEmpty()) throw new IllegalArgumentException("Emtpy list given for Mean computation.");

        return numbers.size() / numbers.stream().map(x -> 1 / x).reduce((x, y) -> x + y).get();
    }
}


Review comment (suggestion):
I would avoid formulas in the doc-strings. What do you think about the following:
```suggestion
    /**
     * @brief computes the [arithmetic mean](https://en.wikipedia.org/wiki/Arithmetic_mean) of the input
     * @param numbers the input numbers
     * @throws IllegalArgumentException empty input
     * @return the arithmetic mean of the input numbers
     */
```

Code after:
package com.thealgorithms.maths;

import java.util.stream.StreamSupport;
import org.apache.commons.collections4.IterableUtils;

/**
 * https://en.wikipedia.org/wiki/Mean
 * <p>
 * by: Punit Patel
 */
public final class Means {

    private Means() {
    }

    /**
     * @brief computes the [Arithmetic Mean](https://en.wikipedia.org/wiki/Arithmetic_mean) of the input
     * @param numbers the input numbers
     * @throws IllegalArgumentException empty input
     * @return the arithmetic mean of the input numbers
     */
    public static Double arithmetic(final Iterable<Double> numbers) {
        checkIfNotEmpty(numbers);
        return StreamSupport.stream(numbers.spliterator(), false).reduce((x, y) -> x + y).get() / IterableUtils.size(numbers);
    }

    /**
     * @brief computes the [Geometric Mean](https://en.wikipedia.org/wiki/Geometric_mean) of the input
     * @param numbers the input numbers
     * @throws IllegalArgumentException empty input
     * @return the geometric mean of the input numbers
     */
    public static Double geometric(final Iterable<Double> numbers) {
        checkIfNotEmpty(numbers);
        return Math.pow(StreamSupport.stream(numbers.spliterator(), false).reduce((x, y) -> x * y).get(), 1d / IterableUtils.size(numbers));
    }

    /**
     * @brief computes the [Harmonic Mean](https://en.wikipedia.org/wiki/Harmonic_mean) of the input
     * @param numbers the input numbers
     * @throws IllegalArgumentException empty input
     * @return the harmonic mean of the input numbers