Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$title is deprecated in /home/www/dev/work/website/lvesu/class/controller/blog/php.php on line 28

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/php.manual.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
PHP - Manual: stats_kurtosis - 互联网笔记

略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: stats_kurtosis

2025-05-13

stats_kurtosis

(PECL stats >= 1.0.0)

stats_kurtosisComputes the kurtosis of the data in the array

说明

stats_kurtosis(array $a): float

Returns the kurtosis of the values in a.

参数

a

The input array

返回值

Returns the kurtosis of the values in a, or false if a is empty or is not an array.

添加备注

用户贡献的备注 1 note

up
1
Angel J. Salinas
9 years ago
// If you don't have the php_stats library, you can use this function:
public static function getKurtosis( $values )
{
$numValues = count( $values );
if ( $numValues == 0 ) {
return 0.0;
}

// Use function from php_stats library if available
if ( function_exists( 'stats_kurtosis' ) ) {
return stats_kurtosis( $values );
}

$mean = array_sum( $values ) / floatval( $numValues );
$add2 = 0.0;
$add4 = 0.0;

foreach ( $values as $value ) {
if ( ! is_numeric( $value ) ) {
return false;
}
$dif = $value - $mean;
$dif2 = $dif * $dif;
$add2 += $dif2;
$add4 += ( $dif2 * $dif2 );
} // foreach values

$variance = $add2 / floatval( $numValues );
return ( $add4 * $numValues ) / ( $add2 * $add2 ) - 3.0;
}

官方地址:https://www.php.net/manual/en/function.stats-kurtosis.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3