PHP - Stats Rand Gen Ipoisson() Function
Definition and Usage
The stats_rand_gen_ipoisson() function can generate a single random deviate from a Poisson distribution.
Syntax
int stats_rand_gen_ipoisson( float $mu )
Parameters
| Sr.No | Parameter | Description |
|---|---|---|
| 1 | mu |
The parameter of the Poisson distribution |
Return Values
The stats_rand_gen_ipoisson() function can return a random deviate from the Poisson distribution with parameter mu.
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 compute random deviation from the Poisson distribution with parameter 1.
<?php var_dump(is_int(stats_rand_gen_ipoisson(1))); ?>
Output
This will produce following result −
bool(true)
Example
In the following example, we compute random deviate from the Poisson distribution with parameter 0.
<?php var_dump(stats_rand_gen_ipoisson(0)); ?>
Output
This will produce following result −
int(0)
Example
Following is an error case. In the following example, we pass mu < 0. A warning is displayed in logs.
<?php // error cases var_dump(stats_rand_gen_ipoisson(-0.1)); // mu < 0 ?>
Output
This will produce following result and a warning in logs PHP Warning: stats_rand_gen_ipoisson(): mu < 0.0 . mu : -1.000000E-1
bool(false)