public function testFlip()
 {
     $array = array(array(1, 2), array(1, 2));
     $this->assertEquals(array(array(1, 1), array(2, 2)), __ll_flip($array));
     // non square test.
     $array = array(array(5, 9, 8), array(1, 2, 3));
     $this->assertEquals(array(array(5, 1), array(9, 2), array(8, 3)), __ll_flip($array));
     $array = array(array(0.1, 0.2, 0.3), array(1, 2, 3), array(-1, -2, -3));
     $this->assertEquals(array(array(0.1, 1, -1), array(0.2, 2, -2), array(0.3, 3, -3)), __ll_flip($array));
 }
function _ll_reposition_centroids($centroids, $belongs_to, $xs)
{
    for ($index = 0; $index < count($centroids); $index++) {
        $my_observations = $belongs_to[$index];
        $my_obs_values = array();
        foreach ($my_observations as $obs) {
            $my_obs_values[] = $xs[$obs];
        }
        $my_obs_values = __ll_flip($my_obs_values);
        $new_position = array();
        foreach ($my_obs_values as $new_dimension) {
            // compute the average of all the observation's positions for the centroids new position.
            $new_position[] = array_sum($new_dimension) / count($new_dimension);
        }
        $centroids[$index] = $new_position;
    }
    return $centroids;
}