# PHP | stats_cdf_chisquare() Function

March 17, 2021

Hello folks! welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we are going to be studying about the PHP stats_cdf_chisquare() Function.

The PHP

The PHP

*stats_cdf_chisquare()*function is used to calculate any one parameter of the*chisquare distribution*given values for the others.## Syntax

Following below is the syntax to use this function -

float stats_cdf_chisquare ( float $par1, float $par2, int $which )

## Parameter Details

Sr.No | Parameter | Description |
---|---|---|

1 | par1 | The first parameter |

2 | par2 | The second parameter |

3 | which | The flag to determine what to be calculated |

## Return Value

This function returns the CDF, its inverse, or one of its parameters of the chisquare distribution. The kind of return value and parameters (

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

*par1*&*par2*) are determined by*which*.The following table list the return value and parameters by which.

- CDF denotes cumulative distribution function.

- x denotes the value of the random variable.

- K denotes the degree of freedom of the chi-square distribution.

which | Return value | par1 | par2 |
---|---|---|---|

1 | CDF | x | k |

2 | x | CDF | k |

3 | k | x | CDF |

## Dependencies

This built-in function was first introduced in statistics extension (PHP version 4.0.0 and PEAR v1.4.0). In this tutorial guide, we used the latest release of stats-2.0.3 (PHP v7.0.0 or newer and PEAR version 1.4.0 or newer).

### Example1

In the following example below, when

*which = 1*, calculate P from (X, DF).- P here is the integral from 0 to X of the chi-square distribution. Input range: [0, 1].

- X is the upper limit of integration of the non-central chi-square distribution. Input range: [0, +infinity].

- DF is the degree of the freedom of the chi-square distribution. Input range: (0, +infinity).

<?php // which = 1 : calculate P from (X, DF) var_dump(round(stats_cdf_chisquare(1, 2, 1), 6)); ?>

#### Output

When the above code is executed, it will produce the following result -

float(0.393469)

### Example2

In the following example below, when

*which = 2*, calculate X from (P, DF).- P here is the integral from 0 to X of the chi-square distribution. Input range: [0, 1].

- X is the upper limit of integration of the non-central chi-square distribution. Input range: [0, +infinity].

- DF is the degree of the freedom of the chi-square distribution. Input range: (0, +infinity).

<?php // which = 2 : calculate X from (P, DF) var_dump(round(stats_cdf_chisquare(0.393469340, 2, 2), 6)); ?>

#### Output

When the above code is executed, it will produce the following result -

float(1)

### Example3

In the following example below, when

*which = 3*, calculate DF from (P, X).- P here is the integral from 0 to X of the chi-square distribution. Input range: [0, 1].

- X is the upper limit of integration of the non-central chi-square distribution. Input range: [0, +infinity].

- DF is the degree of the freedom of the chi-square distribution. Input range: (0, +infinity).

<?php // which = 3 : calculate DF from (P, X) var_dump(round(stats_cdf_chisquare(0.393469340, 1, 3), 6)); ?>

#### Output

When the above code is executed, it will produce the following result -

float(2)

### Example4

Following is an error case. In the following example below

*which<1*, warning message is displayed in logs.<?php var_dump(stats_cdf_chisquare(1, 2, 0)); // which < 1 ?>

#### Output

The above code will produce the following result and a warning in logs

*PHP Warning: stats_cdf_chisquare(): The third parameter ought to be in the 1..3 range*.bool(false)

### Example5

Following is an error case. In the following example below

*which>4*, warning message is displayed in logs.<?php var_dump(stats_cdf_chisquare(1, 2, 4)); // which > 3 ?>

#### Output

The above code will produce the following result and a warning in logs

*PHP Warning: stats_cdf_chisquare(): The third parameter ought to be in the 1..3 range*.bool(false)

Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we are going to be discussing about the

Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.

*stats_cdf_exponential()*Function in PHP.Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.