[Webgame必备]PHP全概率运算函数

2009年09月18日 15:43
/**
 * 全概率计算
 *
 * @param array $input array('a'=>0.5,'b'=>0.2,'c'=>0.4)
 * @param int $pow 小数点位数
 * @return array key
 */
function random($input, $pow = 2) {
    $much = pow(10, $pow);
    $max  = array_sum($input) * $much;
    $rand = mt_rand(1, $max);
    $base = 0;
    foreach ($input as $k => $v) {
        $min ...

日历

« 2012 五月 »
 12345
6789101112
13141516171819
20212223242526
2728293031 

文章分类

Personal(0)
Internet(1)
Developer(4)
Webgame(1)
LazyCMS(0)