当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPExcel_Calculation_Statistical::NORMSINV方法代码示例

本文整理汇总了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);
 }
开发者ID:artmart,项目名称:verare,代码行数:101,代码来源:Calculators.php


注:本文中的PHPExcel_Calculation_Statistical::NORMSINV方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。