• PHP Video Tutorials

PHP - Stats Kurtosis() Function



Definition and Usage

The stats_kurtosis() function can compute the kurtosis of the data in an array. As per wikipedia - Kurtosis (from Greek: κυρτός, kyrtos or kurtos, meaning "curved, arching") is a measure of the "tailedness" of the probability distribution of a real-valued random variable.

Syntax

  float stats_kurtosis( array $a )

Parameters

Sr.No Parameter Description
1

a

The input array

Return Values

The stats_kurtosis() function can return the kurtosis of values in "a" or false if "a" is empty or is not an array.

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 kurtosis array.

<?php
   var_dump(sprintf("%2.9f", stats_kurtosis(array(1,3,5,7))));
   }
?>

Output

This will produce following result −

string(12) "-1.360000000"

Example

Following is an error case. In the following example, we pass empty array. A warning is displayed in logs.

<?php
   // error cases
   var_dump(stats_kurtosis(array()));
?>

Output

This will produce following result and a warning in logs PHP Warning: stats_kurtosis(): The array has zero elements

bool(false)
Advertisements