/** * 得到数组的标准差 * @param unknown type $avg * @param Array $list * @param Boolen $isSwatch * @return unknown type */ public static function getVariance($avg, $list, $isSwatch = FALSE) { $arrayCount = count($list); if($arrayCount == 1 && $isSwatch == TRUE){ return FALSE; }elseif($arrayCount > 0 ){ $total_var = 0; foreach ($list as $lv) $total_var += pow(($lv - $avg), 2); if($arrayCount == 1 && $isSwatch == TRUE) return FALSE; return $isSwatch?sqrt($total_var / (count($list) - 1 )):sqrt($total_var / count($list)); } else return FALSE; }