note 118471 added to function.stats-skew
| From: | AngelJ.Salinas | Date: | Fri, 11 Dec 2015 20:35:28 +0000 |
| Subject: | note 118471 added to function.stats-skew | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-204330@lists.php.net to get a copy of this message | ||
If you don't have the php_stats library, you can use this implementation:
public static function getSkewness( $values )
{
$numValues = count( $values );
if ( $numValues == 0 ) {
return 0.0;
}
// Use function from php_stats library if available
if ( function_exists( 'stats_skew' ) ) {
return stats_skew( $values );
}
$mean = array_sum( $values ) / floatval( $numValues );
$add2 = 0.0;
$add3 = 0.0;
foreach ( $values as $value ) {
if ( ! is_numeric( $value ) ) {
return false;
}
$dif = $value - $mean;
$add2 += ( $dif * $dif );
$add3 += ( $dif * $dif * $dif );
} // foreach values
$variance = $add2 / floatval( $numValues );
return ( $add3 / floatval( $numValues ) ) / pow( $variance, 3 / 2.0 );
}
----
Server IP: 72.52.91.14
Probable Submitter: 85.251.188.122
----
Manual Page -- http://php.net/manual/en/function.stats-skew.php
Edit -- https://master.php.net/note/edit/118471
Del: integrated -- https://master.php.net/note/delete/118471/integrated
Del: useless -- https://master.php.net/note/delete/118471/useless
Del: bad code -- https://master.php.net/note/delete/118471/bad+code
Del: spam -- https://master.php.net/note/delete/118471/spam
Del: non-english -- https://master.php.net/note/delete/118471/non-english
Del: in docs -- https://master.php.net/note/delete/118471/in+docs
Del: other reasons-- https://master.php.net/note/delete/118471
Reject -- https://master.php.net/note/reject/118471
Search -- https://master.php.net/manage/user-notes.php