PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

stats_kurtosis> <stats_dens_weibull
Last updated: Fri, 10 Oct 2008

view this page in

stats_harmonic_mean

(PECL stats:1.0.0-1.0.2)

stats_harmonic_mean値の配列の調和平均を返す

説明

number stats_harmonic_mean ( array $a )
警告

この関数は、 現在のところ詳細な情報はありません。引数のリストのみが 記述されています。

パラメータ

a

返り値



add a note add a note User Contributed Notes
stats_harmonic_mean
Daniel Morris (www.danielxmorris.com)
15-Aug-2008 07:51
I wrote this to calculate harmonic averages in my shares program.  Hopefully this can help someone who doesn't want to use PECL.  The function accepts an unlimited number of arguments without the need to place them into an array, which is better than the way the PECL extension handles the function.

<?php

/**
 *  @author    Daniel Morris
*/
function harmonic () {
   
$num_args = func_num_args ();
    for (
$i = 0; $i < $num_args; $i++) {
       
$sum += 1 / func_get_arg ($i);
    }
    return
$num_args / $sum;
}

// Tests

echo harmonic (1, 2, 3, 4, 5);
echo
harmonic (-1, 3, 4, 10293);
echo
harmonic (-1, -2, -3, -4, -5);

//  2.1897810218978
//  -9.6022389365052
//  -2.1897810218978 

?>

stats_kurtosis> <stats_dens_weibull
Last updated: Fri, 10 Oct 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites