• PHP Video Tutorials

PHP - Stats Stat Binomial Coef() Function



Definition and Usage

The stats_stat_binomial_coef() function can return a binomial coefficient.

Syntax

  float stats_stat_binomial_coef( int $x, int $n )

Parameters

Sr.No Parameter Description
1

x

The number of chooses from the set

2

n

The number of elements in the set

Return Values

The stats_stat_binomial_coef() function can return the binomial coefficient of n choose x.

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 binomial coefficient of 4 choose 0.

<?php
   var_dump(stats_stat_binomial_coef(0, 4));
?>

Output

This will produce following result −

float(1)

Example

In the following example, we compute binomial coefficient of 4 choose 1.

<?php
   var_dump(stats_stat_binomial_coef(1, 4));
?>

Output

This will produce following result −

float(4)
Advertisements