src/Formulas/Mean.php
public function calculate(): FormulasInterface
    {
        if (! $this->dataSet instanceof DataSet) {
            throw new WrongUsageException('DataSet was not provided for mean calculus');
        }

        $dataSetSize = $this->dataSet->getSize();
        $this->result = [];

        foreach ($this->dataSet as $instance) {
            foreach ($instance->getDimensions() as $index => $dimension) {
                $this->result[0][$index] = $this->result[0][$index] ?? 0;
                $this->result[0][$index] += $dimension / $dataSetSize;
            }
            foreach ($instance->getOutputs() as $index => $output) {
                $this->result[1][$index] = $this->result[1][$index] ?? 0;
                $this->result[1][$index] += $output / $dataSetSize;
            }
        }

        return $this;
    }
public function calculate(): FormulasInterface
    {
        if (! $this->dataSet instanceof DataSet) {
            throw new WrongUsageException('DataSet was not provided for mean calculus');
        }

        $dataSetSize = $this->dataSet->getSize();
        $this->result = [];

        foreach ($this->dataSet as $instance) {
            foreach ($instance->getDimensions() as $index => $dimension) {
                $this->result[0][$index] = $this->result[0][$index] ?? 0;
                $this->result[0][$index] += $dimension / $dataSetSize;
            }
            foreach ($instance->getOutputs() as $index => $output) {
                $this->result[1][$index] = $this->result[1][$index] ?? 0;
                $this->result[1][$index] += $output / $dataSetSize;
            }
        }

        return $this;
    }
calculate the mean of the dataSet
@return FormulasInterface
@throws WrongUsageException