标签:public get cti array class randn proc color blog
//概率计算函数 public function get_rand($proArr) { $result = ‘‘; //概率数组的总概率精度 $proSum = array_sum($proArr); //概率数组循环 foreach ($proArr as $key => $proCur) { $randNum = mt_rand(1, $proSum); if ($randNum <= $proCur) { $result = $key; break; } else { $proSum -= $proCur; } } unset ($proArr); return $result; }
标签:public get cti array class randn proc color blog
原文地址:http://www.cnblogs.com/snowfel/p/6206316.html