星级评定,实施威尔逊得分间隔 [英] Star rating, implementing Wilson score interval

查看:74
本文介绍了星级评定,实施威尔逊得分间隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

class Rating
{
  public static function ratingAverage($positive, $total, $power = '0.05')
{
if ($total == 0)
  return 0;

$z = Rating::pnormaldist(1-$power/2,0,1);
$p = 1.0 * $positive / $total;
$s = ($p + $z*$z/(2*$total) - $z * sqrt(($p*(1-$p)+$z*$z/(4*$total))/$total))/(1+$z*$z/$total);
return $s;
  } 

 public static function pnormaldist($qn)
{
  $b = array(
  1.570796288, 0.03706987906, -0.8364353589e-3,
  -0.2250947176e-3, 0.6841218299e-5, 0.5824238515e-5,
  -0.104527497e-5, 0.8360937017e-7, -0.3231081277e-8,
  0.3657763036e-10, 0.6936233982e-12);

if ($qn < 0.0 || 1.0 < $qn)
  return 0.0;

if ($qn == 0.5)
  return 0.0;

$w1 = $qn;

if ($qn > 0.5)
  $w1 = 1.0 - $w1;

$w3 = - log(4.0 * $w1 * (1.0 - $w1));
$w1 = $b[0];

for ($i = 1;$i <= 10; $i++)
  $w1 += $b[$i] * pow($w3,$i);

if ($qn > 0.5)
  return sqrt($w1 * $w3);

return - sqrt($w1 * $w3);
 }
}

在基于5星评分系统(其中1星= 1点)计算平均评分时,可以利用此功能吗?如果是这样,我想举一个使用链接类的示例.还是应该选择贝叶斯估计"之类的方法?

Can I make use of this when calculating the average rating based on a 5 star rating system (where 1 star = 1 point)? And if so, I would like an example using the linked class. Or should I go for something like the "Bayesian estimate"?

推荐答案

我认为这是不可能的.威尔逊区间仅适用于2个变量.但是,您无需计算二项式分布中的正数或成功数,而可以计算5星级评分的方差: http://www.goproblems.com/test/wilson/wilson.php?v1=0&v2=0&v3=3&v4=0&v5=0

I don't think this is possible. Wilson intervall is for 2 variables only. But instead of using the positive or successes in a binominal distribution you can calculate the variance of the 5-star rating: http://www.mathsisfun.com/data/standard-deviation.html. Here is an adapted wilson function: http://www.goproblems.com/test/wilson/wilson.php?v1=0&v2=0&v3=3&v4=0&v5=0

这篇关于星级评定,实施威尔逊得分间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆