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; }
?> </div></div><hr /> <div><div style="float: left;">E-Mail:</div><div style="float: right;"><?php print $mail; ?> </div></div><hr /> <div><div style="float: left;">MsN:</div><div style="float: right;"><?php print check_null($row_info[2], 1); ?> </div></div><hr /> <div><div style="float: left;">Sito Web:</div><div style="float: right;"><?php print check_null($row_info[1], 2); ?> </div></div><hr /> <div><div style="float: left;">karma:</div><div style="float: right;"><?php print karma(nick2uid($row[3])); ?> </div></div><hr /> <div> <div style="float: left;"> <form method="POST" action="karma.php" /> <input type = 'hidden' name = 'topic_id' value = '<?php print $id; ?> ' > <input type = 'hidden' name = 'user_id' value = '<?php print nick2uid($row[3]); ?> '> <input class='karma_più' type = 'submit' value = '+1' name = 'vote' > <input class='karma_meno' type = 'submit' value = '-1' name = 'vote'> </form>