Code Duplication    Length = 16-16 lines in 2 locations

src/Phpml/Preprocessing/Normalizer.php 2 locations

@@ 83-98 (lines=16) @@
80
        }
81
    }
82
83
    private function normalizeL1(array &$sample)
84
    {
85
        $norm1 = 0;
86
        foreach ($sample as $feature) {
87
            $norm1 += abs($feature);
88
        }
89
90
        if (0 == $norm1) {
91
            $count = count($sample);
92
            $sample = array_fill(0, $count, 1.0 / $count);
93
        } else {
94
            foreach ($sample as &$feature) {
95
                $feature /= $norm1;
96
            }
97
        }
98
    }
99
100
    private function normalizeL2(array &$sample)
101
    {
@@ 100-115 (lines=16) @@
97
        }
98
    }
99
100
    private function normalizeL2(array &$sample)
101
    {
102
        $norm2 = 0;
103
        foreach ($sample as $feature) {
104
            $norm2 += $feature * $feature;
105
        }
106
        $norm2 = sqrt((float) $norm2);
107
108
        if (0 == $norm2) {
109
            $sample = array_fill(0, count($sample), 1);
110
        } else {
111
            foreach ($sample as &$feature) {
112
                $feature /= $norm2;
113
            }
114
        }
115
    }
116
117
    private function normalizeSTD(array &$sample)
118
    {