protected function resample(): array
    {
        $weights = $this->weights;
        $std = StandardDeviation::population($weights);
        $mean = Mean::arithmetic($weights);
        $min = min($weights);
        $minZ = (int) round(($min - $mean) / $std);

        $samples = [];
        $targets = [];
        foreach ($weights as $index => $weight) {
            $z = (int) round(($weight - $mean) / $std) - $minZ + 1;
            for ($i = 0; $i < $z; ++$i) {
                if (random_int(0, 1) == 0) {
                    continue;
                }

                $samples[] = $this->samples[$index];
                $targets[] = $this->targets[$index];
            }
        }

        return [$samples, $targets];
    }
protected function resample(): array
    {
        $weights = $this->weights;
        $std = StandardDeviation::population($weights);
        $mean = Mean::arithmetic($weights);
        $min = min($weights);
        $minZ = (int) round(($min - $mean) / $std);

        $samples = [];
        $targets = [];
        foreach ($weights as $index => $weight) {
            $z = (int) round(($weight - $mean) / $std) - $minZ + 1;
            for ($i = 0; $i < $z; ++$i) {
                if (random_int(0, 1) == 0) {
                    continue;
                }

                $samples[] = $this->samples[$index];
                $targets[] = $this->targets[$index];
            }
        }

        return [$samples, $targets];
    }
protected function resample ( ) : array { $ weights = $ this -> weights ; $ std = StandardDeviation :: population ( $ weights ) ; $ mean = Mean :: arithmetic ( $ weights ) ; $ min = min ( $ weights ) ; $ minZ = ( int ) round ( ( $ min - $ mean ) / $ std ) ; $ samples = [ ] ; $ targets = [ ] ; foreach ( $ weights as $ index => $ weight ) { $ z = ( int ) round ( ( $ weight - $ mean ) / $ std ) - $ minZ + 1 ; for ( $ i = 0 ; $ i < $ z ; ++ $ i ) { if ( random_int ( 0 , 1 ) == 0 ) { continue ; } $ samples [ ] = $ this -> samples [ $ index ] ; $ targets [ ] = $ this -> targets [ $ index ] ; } } return [ $ samples , $ targets ] ; }
Resamples the dataset in accordance with the weights and
returns the new dataset
Resamples the dataset in accordance with the weights and returns the new dataset