如何根据票数/分数/样本/等计算均值? [英] How to calculate mean based on number of votes/scores/samples/etc?

查看:195
本文介绍了如何根据票数/分数/样本/等计算均值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为简单起见,我们有一组可能的分数{0,1,2}.有没有一种方法可以根据分数的数量来计算平均值,而无需进入毛茸茸的查找表等来进行95%置信区间计算?

dreeves在此发布了对此的解决方案:解决方案

您可以在对结果进行排名时给它一个加权分数,而不是仅仅显示到目前为止的平均投票,方法是将投票数乘以某些函数

C#中的一个示例(因为正是 I 我最了解...),可以轻松地将其翻译成您选择的语言:

double avgScore = Math.Round(sum / n);
double rank = avgScore * Math.Log(n);

在这里,我已经使用n的对数作为加权函数-但是,只有在投票数不能太小或太大的情况下,它才能很好地工作. 最优"大小到底是多少取决于您希望票数多少重要.

如果您喜欢对数方法,但底数10不能真正用于您的投票计数,则可以轻松地使用其他底数.例如,改为在基本3中执行此操作:

double rank = avgScore * Math.Log(n, 3);

您应该使用哪种功能进行权衡,最好由您希望获得的投票数的数量级决定.

您还可以通过定义使用自定义加权功能

double rank = avgScore * w(n);

其中,w(n)根据票数返回权重值.然后,根据需要定义w(n),例如:

double w(int n) {
    // caution! ugly example code ahead...
    // if you even want this approach, at least use a switch... :P

    if (n > 100) { 
        return 10; 
    } else if (n > 50) {
        return 8;
    } else if (n > 40) {
        return 6;
    } else if (n > 20) {
        return 3;
    } else if (n > 10) {
        return 2;
    } else {
        return 1;
    }
}

For simplicity say we have a sample set of possible scores {0, 1, 2}. Is there a way to calculate a mean based on the number of scores without getting into hairy lookup tables etc for a 95% confidence interval calculation?

dreeves posted a solution to this here: How can I calculate a fair overall game score based on a variable number of matches?

Now say we have 2 scenarios ...

Scenario A) 2 votes of value 2 result in SE=0 resulting in the mean to be 2

Scenario B) 10000 votes of value 2 result in SE=0 resulting in the mean to be 2

I wanted Scenario A to be some value less than 2 because of the low number of votes, but it doesn't seem like this solution handles that (dreeve's equations hold when you don't have all values in your set equal to each other). Am I missing something or is there another algorithm I can use to calculate a better score.

The data available to me is:

  • n (number of votes)
  • sum (sum of votes)
  • {set of votes} (all vote values)

Thanks!

解决方案

You could just give it a weighted score when ranking results, as opposed to just displaying the average vote so far, by multiplying with some function of the number of votes.

An example in C# (because that's what I happen to know best...) that could easily be translated into your language of choice:

double avgScore = Math.Round(sum / n);
double rank = avgScore * Math.Log(n);

Here I've used the logarithm of n as the weighting function - but it will only work well if the number of votes is neither too small or too large. Exactly how large is "optimal" depends on how much you want the number of votes to matter.

If you like the logarithmic approach, but base 10 doesn't really work with your vote counts, you could easily use another base. For example, to do it in base 3 instead:

double rank = avgScore * Math.Log(n, 3);

Which function you should use for weighing is probably best decided by the order of magnitude of the number of votes you expect to reach.

You could also use a custom weighting function by defining

double rank = avgScore * w(n);

where w(n) returns the weight value depending on the number of votes. You then define w(n) as you wish, for example like this:

double w(int n) {
    // caution! ugly example code ahead...
    // if you even want this approach, at least use a switch... :P

    if (n > 100) { 
        return 10; 
    } else if (n > 50) {
        return 8;
    } else if (n > 40) {
        return 6;
    } else if (n > 20) {
        return 3;
    } else if (n > 10) {
        return 2;
    } else {
        return 1;
    }
}

这篇关于如何根据票数/分数/样本/等计算均值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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