本文介绍了我怎样才能使这个函数恢复到Kurtosis,它只是输出现在的'Inf'。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?php
require_once 'variance.php';
require_once 'mean.php';
function kurtosis($valArray, $isSample, $isExcess){
$mean = mean($valArray);
$variance = 0;
$mult = 0;
$moment4 = 0;
$length = 0;
foreach($valArray as $k => $moment4):
$mult -= $mean;
$mult *= $mult;
$mult *= $mult;
$moment4 += $mult;
$length++;
endforeach;
$variance = variance($valArray, $mean, $isSample);
$moment2 = ($variance *= $variance);
$kurt = $length *($moment4 / $moment2);
//normal kurtosis
if((!$isSample) && (!$isExcess)):
$kurtosis = $kurt;
//excess kurtosis
elseif(($isExcess) && (!$isSample)):
$kurtosis = ($kurt - 3);
// sample kurtosis
elseif((!$isExcess) && ($isSample)):
$n3 = ($length * $length * $length);
$n2 = ($length * $length);
$kurt = $n2 / $n3;
$kurtosis = $kurt *($moment4 / $moment2);
//sample excess kurtosis
else:
$n3 = ($length * $length * $length);
$n2 = ($length * $length);
$kurt = ( ($n2 / $n3) * ($moment4 / $moment2) );
$kurtosis = $kurt - 3;
endif;
return $kurtosis;
}
?>
推荐答案
这篇关于我怎样才能使这个函数恢复到Kurtosis,它只是输出现在的'Inf'。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!