• PHP Video Tutorials

PHP - Stats Rand Gen Noncentral f() Function



Definition and Usage

The stats_rand_gen_noncentral_f() function can generate a random deviate from the non-central F distribution.

Syntax

  float stats_rand_gen_noncentral_f( float $dfn, float $dfd, float $xnonc )

Parameters

Sr.No Parameter Description
1

dfn

The degrees of freedom of the numerator

2

dfd

The degrees of freedom of the numerator

3

xnonc

The non-centrality parameterv

Return Values

The stats_rand_gen_noncentral_f() function can return a random deviate from the non-central F distribution, where the degrees of freedoms are dfn (numerator) and dfd (denominator), and the non-centrality parameter is xnonc.

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, we random deviation from the non-central F distribution, where the degrees of freedoms are 2 (numerator) and 3 (denominator), and the non-centrality parameter is 4.

<?php
   var_dump(is_float(stats_rand_gen_noncentral_f(2, 3, 4)));
?>

Output

This will produce following result −

bool(true)

Example

Following is an error case. In the following example, we pass dfn < 1. A warning is displayed in logs.

<?php
   // error cases
   var_dump(stats_rand_gen_noncentral_f(0.9, 3, 4));    // dfn < 1
?>

Output

This will produce following result and a warning in logs PHP Warning: stats_rand_gen_noncentral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn: 9.000000E-1 dfd: 3.000000E+0 xnonc: 4.000000E+0

bool(false)

Example

Following is an error case. In the following example, we pass dfd < 0. A warning is displayed in logs.

<?php
   // error cases
   var_dump(stats_rand_gen_noncentral_f(2, -0.1, 4));   // dfd < 0
?>

Output

This will produce following result and a warning in logs PHP Warning: stats_rand_gen_noncentral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn: 2.000000E+0 dfd: -1.000000E-1 xnonc: 4.000000E+0

bool(false)

Example

Following is an error case. In the following example, we pass dfd == 0. A warning is displayed in logs.

<?php
   // error cases
   var_dump(stats_rand_gen_noncentral_f(2, 0, 4));      // dfd == 0
?>

Output

This will produce following result and a warning in logs PHP Warning: stats_rand_gen_noncentral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn: 2.000000E+0 dfd: 0.000000E+0 xnonc: 4.000000E+0

bool(false)

Example

Following is an error case. In the following example, we pass xnonc < 0. A warning is displayed in logs.

<?php
   // error cases
   var_dump(stats_rand_gen_noncentral_f(2, 3, -0.1));   // xnonc < 0
?>

Output

This will produce following result and a warning in logs PHP Warning: stats_rand_gen_noncentral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn: 2.000000E+0 dfd: 3.000000E+0 xnonc: -1.000000E-1

bool(false)
Advertisements