本文整理汇总了PHP中Rating::ratingAverage方法的典型用法代码示例。如果您正苦于以下问题:PHP Rating::ratingAverage方法的具体用法?PHP Rating::ratingAverage怎么用?PHP Rating::ratingAverage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rating
的用法示例。
在下文中一共展示了Rating::ratingAverage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: karma_calculate
function karma_calculate($statuses) {
$return = new stdClass();
$daily_karma = array();
//$daily_status_count = array();
$comment_count = 0;
$like_count = 0;
$denominator = 0.;
foreach ($statuses as $status) {
// get the timestamp of the date
$daystamp = unixtojd(strtotime(substr($status['updated_time'], 0, 11)));
$karma = karma($status);
array_accum($daily_karma, $daystamp, $karma);
//array_accum($daily_status_count, $daystamp, 1);
$comment_count += $status['comment_count'];
$like_count += $status['like_count'];
// For the Wilson score, we need to find a proportion of "positive values". Therefore we set an absolute value for max karma per status message.
$denominator += max($karma, 10);
}
//print_r($daily_status_count);
//print_r(array_fill_missing_desc($daily_status_count));
//print 'sharpe: ' . sharpe_ratio($a);
//print "\nsum:" . array_sum($daily_karma) . "\n";
$wilson_score = Rating::ratingAverage(array_sum($daily_karma), $denominator);
$return->pop_index = $wilson_score * 100;
$daily_karma_full = array_fill_missing_desc($daily_karma);
$return->comment_count = $comment_count;
$return->like_count = $like_count;
$return->day_count = count($daily_karma);
$return->status_count = count($statuses);
return $return;
}