本文整理汇总了PHP中PHPExcel_Calculation_Statistical::NORMSINV方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Calculation_Statistical::NORMSINV方法的具体用法?PHP PHPExcel_Calculation_Statistical::NORMSINV怎么用?PHP PHPExcel_Calculation_Statistical::NORMSINV使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Calculation_Statistical
的用法示例。
在下文中一共展示了PHPExcel_Calculation_Statistical::NORMSINV方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CalcAllStats1
//.........这里部分代码省略.........
$countGoodDays++;
}
if ($r < 1) {
//threshold = 0
$sumBenchMinusTargetOnBadDays += $returnBenchmark[$returnCount] - $r;
$sumBenchMinusTargetSquaredOnBadDays += pow($returnBenchmark[$returnCount] - $r, 2);
}
if ($r > $returnMax) {
$returnMax = $r;
}
if ($r < $returnMin) {
$returnMin = $r;
}
$returnCount++;
}
if ($returnCount > 1) {
// calculate some figures
$returnTargetCumulative -= 1.0;
$returnBenchCumulative -= 1.0;
$averageTarget = $sumTarget / $returnCount;
$averageBench = $sumBench / $returnCount;
$averageTargetMinusBench = $sumTargetMinusBench / $returnCount;
$averageBenchMinusTargetOnBadDays = $sumBenchMinusTargetOnBadDays / $returnCount;
$averageBenchMinusTargetSquaredOnBadDays = $sumBenchMinusTargetSquaredOnBadDays / $returnCount;
$covarTargetBench = ($sumTargetTimesBench - $sumTarget * $sumBench / $returnCount) / ($returnCount - 1);
// second loop
$i = 0;
foreach ($returnTarget as $r) {
$varianceTarget += pow($r - $averageTarget, 2);
$varianceBench += pow($r - $averageBench, 2);
$varianceTargetMinusBench += pow($r - $averageBench - $averageTargetMinusBench, 2);
$i++;
}
// calculate the output
$varianceTarget /= $returnCount - 1;
$varianceBench /= $returnCount - 1;
$varianceTargetMinusBench /= $returnCount - 1;
$volTarget = sqrt($varianceTarget) * sqrt(240);
$volBench = sqrt($varianceBench) * sqrt(240);
$volTargetMinusBench = sqrt($varianceTargetMinusBench) * sqrt(240);
if ($varianceBench == 0) {
$beta = 0;
} else {
$beta = $covarTargetBench / $varianceBench;
}
if ($volTarget > 0) {
$sharpe = $returnTargetCumulative / $volTarget;
} else {
$sharpe = 0;
}
$alpha = $averageTarget - $beta * $averageBench;
if ($beta == 0) {
$treynor = 0;
} else {
$treynor = $returnTargetCumulative / $beta;
}
$trackingError = $volTargetMinusBench;
if ($volTargetMinusBench > 0) {
$infoQuota = ($returnTargetCumulative - $returnBenchCumulative) / $volTargetMinusBench;
} else {
$infoQuota = 0;
}
$consistency = $countGoodDays / $returnCount;
$x = pow(($returnCount * $sumTargetSquared - pow($sumTarget, 2)) * ($returnCount * $sumBenchSquared - pow($sumBench, 2)), 1 / 2);
//$x = pow(($returnCount*$sumTargetTimesBench-$sumTarget*$sumBench)/pow(($returnCount*$sumTargetSquared-pow($sumTarget,2))*($returnCount*$sumBenchSquared-pow($sumBench,2)),1/2),2);
if ($x > 0) {
$R2 = pow(($returnCount * $sumTargetTimesBench - $sumTarget * $sumBench) / $x, 2);
} else {
$R2 = 0;
}
if ($averageBenchMinusTargetOnBadDays == 0) {
$omega = 0;
$sortino = 0;
// "Div/Null!";
} else {
$omega = 1 + $averageTargetMinusBench / $averageBenchMinusTargetOnBadDays;
$sortino = $averageTargetMinusBench / pow($averageBenchMinusTargetOnBadDays, 1 / 2);
}
$VaR = $averageTargetMinusBench + $volTarget * PHPExcel_Calculation_Statistical::NORMSINV(0.01);
//$VaR=$averageTargetMinusBench+$volTarget*$this->inverse_ncdf(0.01);
} else {
$volTarget = 0;
$sharpe = 0;
$beta = 0;
$treynor = 0;
$trackingError = 0;
$infoQuota = 0;
$consistency = 0;
$R2 = 0;
$VaR = 0;
$averageTarget = 1;
$returnMax = 1;
$returnMin = 1;
$sortino = 0;
$omega = 0;
$averageTargetMinusBench = 0;
$averageBenchMinusTargetOnBadDays = 0;
}
return array($volTarget, $sharpe, $alpha, $beta, $treynor, $trackingError, $infoQuota, $consistency, $R2, $VaR, $averageTarget - 1, $returnMax - 1, $returnMin - 1, $sortino, $omega, $averageTargetMinusBench, $averageBenchMinusTargetOnBadDays);
}