function improvedPageHinkley($list, $lambda)
{
    $alphaPH = function ($t) {
        $used_list = array_slice($list, 0, $t);
        return sqrt(ll_variance($used_list));
    };
    $mean = ll_mean($used_list);
    return _PageHinkleyStatistic($list, count($list), ll_sign($list[count($list) - 1] - $mean), $alphaPH(count($list)) / 2) > $lambda;
}
function ll_variance($array)
{
    $mean = ll_mean($array);
    $sum_difference = 0;
    $n = count($array);
    for ($i = 0; $i < $n; $i++) {
        $sum_difference += pow($array[$i] - $mean, 2);
    }
    $variance = $sum_difference / $n;
    return $variance;
}
 protected function computeParameters($xs)
 {
     if (!is_array($xs[0])) {
         $xs = $this->arrayNonArray($xs);
     }
     $xs_columns = ll_transpose($xs);
     foreach ($xs_columns as $index => $column) {
         $this->mean[$index] = ll_mean($column);
         $this->variance[$index] = ll_variance($column);
     }
 }