当前位置: 首页>>代码示例>>PHP>>正文


PHP Rating::ratingAverage方法代码示例

本文整理汇总了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;
}
开发者ID:ryandao,项目名称:Facebook-Status-Time-Capsule,代码行数:37,代码来源:karma.php


注:本文中的Rating::ratingAverage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。