• PHP Video Tutorials

PHP - Stats CDF Noncentral f() Function



Definition and Usage

The stats_cdf_noncentral_f() function can calculate any one parameter of non-central F distribution given values for the others.

Syntax

float stats_cdf_noncentral_f( float $par1, float $par2, float $par3, float $par4, int $which )

Parameters

Sr.No Parameter Description
1

par1

The first parameter

2

par2

The second parameter

3

par3

The third parameter

4

par4

The fourth parameter

5

which

The flag to determine what to be calculated

Return Values

The stats_cdf_noncentral_f() function can return the cumulative distribution function, its inverse, or one of its parameters of the non-central F distribution. The kind of return value and parameters (par1, par2, par3, and par4) have determined by which.

Return value and parameters

The following table lists the return value and parameters by which.

  • CDF denotes cumulative distribution function

  • x denotes the value of the random variable

  • nu1,nu2 denotes the degree of freedoms of the distribution

  • lambda denotes the non-centrality parameter of the distribution

which Return value par1 par2 par3 par4
1 CDF x nu1 nu2 lambda
2 x CDF nu1 nu2 lambda
3 nu1 x CDF nu2 lambda
4 nu2 x CDF nu1 lambda
5 lambda x CDF nu1 nu2

Dependencies

This function was first introduced in statistics extension (PHP 4.0.0 and PEAR 1.4.0). We have used latest release of stats-2.0.3 (PHP 7.0.0 or newer and PEAR 1.4.0 or newer) for this tutorial.

Example

In the following example when which=1, calculate P from (F, DFN, DFD, PNONC).

  • P is the integral from 0 to F of the non-central f-density.

  • F is the upper limit of integration of the non-central f-density.

  • DFN is the degrees of freedom of the numerator sum of squares.

  • DFD is the degrees of freedom of the denominator sum of squares.

  • PNONC is the non-centrality parameter of the non-central f-density.

<?php
   // which = 1 : calculate P from (F, DFN, DFD, PNONC)
   var_dump(round(stats_cdf_noncentral_f(5, 2, 3, 4, 1), 6));
?>

Output

This will produce following result −

float(0.650459)

Example

In the following example when which=2, calculate F from (P, DFN, DFD, PNONC).

  • P is the integral from 0 to F of the non-central f-density.

  • F is the upper limit of integration of the non-central f-density.

  • DFN is the degrees of freedom of the numerator sum of squares.

  • DFD is the degrees of freedom of the denominator sum of squares.

  • PNONC is the non-centrality parameter of the non-central f-density.

<?php
   // which = 2 : calculate F from (P, DFN, DFD, PNONC)
   var_dump(round(stats_cdf_noncentral_f(0.650459043, 2, 3, 4, 2), 6));
?>

Output

This will produce following result −

float(5)

Example

In the following example when which=3, calculate DFN from (P, F, DFD, PNONC).

  • P is the integral from 0 to F of the non-central f-density.

  • F is the upper limit of integration of the non-central f-density.

  • DFN is the degrees of freedom of the numerator sum of squares.

  • DFD is the degrees of freedom of the denominator sum of squares.

  • PNONC is the non-centrality parameter of the non-central f-density.

<?php
   // which = 3 : calculate DFN from (P, F, DFD, PNONC)
   var_dump(round(stats_cdf_noncentral_f(0.650459043, 5, 3, 4, 3), 6));
?>

Output

This will produce following result −

float(2)

Example

In the following example when which=4, calculate DFD from (P, F, DFN, PNONC).

  • P is the integral from 0 to F of the non-central f-density.

  • F is the upper limit of integration of the non-central f-density.

  • DFN is the degrees of freedom of the numerator sum of squares.

  • DFD is the degrees of freedom of the denominator sum of squares.

  • PNONC is the non-centrality parameter of the non-central f-density.

<?php
   // which = 4 : calculate DFD from (P, F, DFN, PNONC)
   var_dump(round(stats_cdf_noncentral_f(0.650459043, 5, 2, 4, 4), 6));
?>

Output

This will produce following result −

float(3)

Example

In the following example when which=5, calculate PNONC from (P, F, DFN, DFD).

  • P is the integral from 0 to F of the non-central f-density.

  • F is the upper limit of integration of the non-central f-density.

  • DFN is the degrees of freedom of the numerator sum of squares.

  • DFD is the degrees of freedom of the denominator sum of squares.

  • PNONC is the non-centrality parameter of the non-central f-density.

<?php
   // which = 5 : calculate PNONC from (P, F, DFN, DFD)
   var_dump(round(stats_cdf_noncentral_f(0.650459043, 5, 2, 3, 5), 6));
?>

Output

This will produce following result −

float(4)

Example

Following is an error case. In the following example which<1, warning is displayed in logs.

<?php
   var_dump(round(stats_cdf_noncentral_f(1, 2, 3, 4, 0), 6));      // which < 1
?>

Output

This will produce following result and a warning in logs PHP Warning: stats_cdf_noncentral_f(): Fifth parameter should be in the 1..5 range

float(0)

Example

Following is an error case. In the following example which>5, warning is displayed in logs.

<?php
   var_dump(round(stats_cdf_noncentral_f(1, 2, 3, 4, 6), 6));      // which > 5
?>

Output

This will produce following result and a warning in logs PHP Warning: stats_cdf_noncentral_f(): Fifth parameter should be in the 1..5 range

float(0)
Advertisements