加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

来自Ruby Wilson的C#得分

发布时间:2020-12-17 02:51:40 所属栏目:百科 来源:网络整理
导读:任何人都可以帮助我将其转换为C#.这实际上伤害了我的大脑. http://www.evanmiller.org/how-not-to-sort-by-average-rating.html require 'statistics2'def ci_lower_bound(pos,n,power) if n == 0 return 0 end z = Statistics2.pnormaldist(1-power/2) phat
任何人都可以帮助我将其转换为C#.这实际上伤害了我的大脑.

http://www.evanmiller.org/how-not-to-sort-by-average-rating.html

require 'statistics2'

def ci_lower_bound(pos,n,power)
    if n == 0
        return 0
    end
    z = Statistics2.pnormaldist(1-power/2)
    phat = 1.0*pos/n
    (phat + z*z/(2*n) - z * Math.sqrt((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n)
end

这是什么意思?

Statistics2.pnormaldist(1-power/2)

解决方法

如果有人有兴趣……

做更多关于pnormaldist的谷歌搜索引导我到这个stackoverflow artice:Objective-C implementation of the Wilson Score Interval

我将这个目标-c转换为C#,并且完全未经测试

public class WilsonScore
{
    private static double pnormaldist(double qn)
    {
        double[] b = { 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;

        double w1 = qn;
        if (qn > 0.5)
            w1 = 1.0 - w1;
        double w3 = -Math.Log(4.0 * w1 * (1.0 - w1));
        w1 = b[0];
        int i = 1;
        for (; i < 11; i++)
            w1 += b[i] * Math.Pow(w3,i);

        if (qn > 0.5)
            return Math.Sqrt(w1 * w3);
        return -Math.Sqrt(w1 * w3);
    }

    public static double ci_lower_bound(int pos,int n,double power)
    {
        if (n == 0)
            return 0.0;
        double z = pnormaldist(1 - power / 2);
        double phat = 1.0 * pos / n;
        return (phat + z * z / (2 * n) - z * Math.Sqrt((phat * (1 - phat) + z * z / (4 * n)) / n)) / (1 + z * z / n);
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读