CDF() public static method

cdf = 1 - ½Iₓ₍t₎(ν/2, ½) ν where x(t) = ------ t² + ν Iₓ₍t₎(ν/2, ½) is the regularized incomplete beta function
public static CDF ( number $t, integer )
$t number t score
integer degrees of freedom > 0
Example #1
0
 /**
  * Cumulative distribution function
  *
  * Fᵥ,ᵤ(x) = Fᵥ,ᵤ(x),      if x ≥ 0
  *         = 1 - Fᵥ,₋ᵤ(x)  if x < 0
  *
  * @param number $x
  * @param int    $ν Degrees of freedom
  * @param number $μ Noncentrality parameter
  *
  * @return number
  */
 public static function CDF($x, int $ν, $μ)
 {
     Support::checkLimits(self::LIMITS, ['x' => $x, 'ν' => $ν, 'μ' => $μ]);
     if ($μ == 0) {
         return StudentT::CDF($x, $ν);
     }
     if ($x >= 0) {
         return self::F($x, $ν, $μ);
     }
     return 1 - self::F($x, $ν, -$μ);
 }
Example #2
0
 /**
  * The probabilty associated with each parameter's t value
  *
  * t probability = Student's T CDF(t,ν)
  *
  *  where:
  *    t = t value
  *    ν = n - p - alpha  degrees of freedom
  *
  *  alpha = 1 if the regression includes a constant term
  *
  * @return array [m => p, b => p]
  */
 public function tProbability() : array
 {
     $ν = $this->ν;
     $t = $this->tValues();
     return ['m' => StudentT::CDF($t['m'], $ν), 'b' => StudentT::CDF($t['b'], $ν)];
 }
Example #3
0
 /**
  * One-sample Student's t-test
  * Compares sample mean to the population mean.
  * https://en.wikipedia.org/wiki/Student%27s_t-test
  *
  *     Hₐ - H₀   M - μ   M - μ   M - μ
  * z = ------- = ----- = ----- = -----
  *        σ        σ      SEM     σ/√n
  *
  * p1 = CDF below if left tailed
  *    = CDF above if right tailed
  * p2 = CDF outside
  *
  * @param number $Hₐ Alternate hypothesis (M Sample mean)
  * @param number $s  SD of sample
  * @param int    $n  Sample size
  * @param number $H₀ Null hypothesis (μ₀ Population mean)
  *
  * @return array [
  *   z  => z score
  *   p1 => one-tailed p value (left or right tail depends on how Hₐ differs from H₀)
  *   p2 => two-tailed p value
  * ]
  */
 public static function tTestOneSample($Hₐ, $s, $n, $H₀) : array
 {
     // Calculate test statistic t
     $t = self::tScore($Hₐ, $s, $n, $H₀);
     // Degrees of freedom
     $ν = $n - 1;
     // One- and two-tailed P values
     if ($Hₐ < $H₀) {
         $p1 = StudentT::CDF($t, $ν);
     } else {
         $p1 = StudentT::above($t, $ν);
     }
     $p2 = StudentT::outside(-abs($t), abs($t), $ν);
     return ['t' => $t, 'p1' => $p1, 'p2' => $p2];
 }