protected function logLikelihood(Matrix $z) : array
    {
        $likelihoods = array_fill(0, $z->n(), 0.);
        
        foreach ($z as $i => $values) {
            [$edges, $counts, $densities] = $this->histograms[$i];

            foreach ($values as $j => $value) {
                foreach ($edges as $k => $edge) {
                    if ($value < $edge) {
                        $likelihoods[$j] += $densities[$k];

                        break 1;
                    }
                }
            }
        }

        foreach ($likelihoods as &$likelihood) {
            $likelihood /= $this->estimators;
        }

        return $likelihoods;
    }