<?php // PAR COSINUS function getScore($positive, $total, $power) { if($total == 0) return 0; $z = cos(1 - $power / 2); $zs = $z * $z; $phat = $positive / $total; return ($phat + $zs / (2 * $total) - $z * sqrt(($phat * (1 - $phat) + $zs / (4 * $total)) / $total)) / (1 + $zs / $total); } // PAR NORMDIST function getScoreNormDist($positive, $total, $power) { if($total == 0) return 0; $z = normDist(1 - $power / 2); $zs = $z * $z; $phat = $positive / $total; return ($phat + $zs / (2 * $total) - $z * sqrt(($phat * (1 - $phat) + $zs / (4 * $total)) / $total)) / (1 + $zs / $total); } // NORMDIST function normDist($num) { $c1 = 2.506628; $c2 = 0.3193815; $c3 = -0.3565638; $c4 = 1.7814779; $c5 = -1.821256; $c6 = 1.3302744; if($num > 0) $w = 1; else $w = -1; $y = 1 / (1 + 0.2316419 * $w * $num); return 0.5 + $w * (0.5 - (exp( - $num * $num / 2) / $c1) * ($y * ($c2 + $y * ($c3 + $y * ($c4 + $y * ($c5 + $y * $c6)))))); }