protected function membership(array $sample) : array
    {
        $membership = $distances = [];

        foreach ($this->centroids as $centroid) {
            $distances[] = $this->kernel->compute($sample, $centroid);
        }

        $total = array_sum($distances) ?: EPSILON;

        foreach ($distances as $distance) {
            $membership[] = $distance / $total;
        }

        return $membership;
    }
protected function membership(array $sample) : array
    {
        $membership = $distances = [];

        foreach ($this->centroids as $centroid) {
            $distances[] = $this->kernel->compute($sample, $centroid);
        }

        $total = array_sum($distances) ?: EPSILON;

        foreach ($distances as $distance) {
            $membership[] = $distance / $total;
        }

        return $membership;
    }
protected function membership ( array $ sample ) : array { $ membership = $ distances = [ ] ; foreach ( $ this -> centroids as $ centroid ) { $ distances [ ] = $ this -> kernel -> compute ( $ sample , $ centroid ) ; } $ total = array_sum ( $ distances ) ? : EPSILON ; foreach ( $ distances as $ distance ) { $ membership [ ] = $ distance / $ total ; } return $ membership ; }
Return the membership of a sample to each of the centroids.

@param array $sample
@return array
Return the membership of a sample to each of the centroids .