# 【推荐算法】威尔逊区间排序算法

### 什么是威尔逊区间？

[En]

More than 10,000 words are omitted here

[En]

Suppose you are already a mature programmer. There is no need to give you a theory. Go straight to the code.

### php版本

echo  wilsonScore_2(300, 13/300, 2);
function  wilsonScore_2($n,$p, $z){$a_1 = ((1 / (2 * $n)) * ( pow($z,2)));
$b_1 =$z * sqrt(($p * (1 -$p) / $n) + ( pow($z,2) / (4 * (pow($n,2)))));$c_1 = 1 + ((1 / $n) * ( pow($z,2)));
$numerator =$p + $a_1 -$b_1;
$res =$numerator/$c_1; return$res;
}



### python版本

def _cal_wilson_lower_level(n, p, z):
"""&#x8BA1;&#x7B97;&#x5A01;&#x5C14;&#x900A;&#x533A;&#x95F4;&#x4E0B;&#x9650;
# n: int, &#x6D4F;&#x89C8;&#x6B21;&#x6570;
# p: float, &#x6D4F;&#x89C8;&#x4E0B;&#x8F7D;&#x6BD4;
# z: float, z&#x503C;"""

numerator = p + ((1 / (2 * n)) * (z ** 2)) - \
(z * (((p * (1 - p) / n) +
(z ** 2 / (4 * (n ** 2)))) ** (1 / 2)))
denominator = 1 + ((1 / n) * (z ** 2))
return numerator / denominator

_cal_wilson_lower_level(300, 13/300, 2)



[En]

Welcome to do technical friends to communicate with us! Please take a detour, code change the world QQ group: 453011886

Original: https://www.cnblogs.com/richerdyoung/p/14072040.html
Author: 依然范儿特西
Title: 【推荐算法】威尔逊区间排序算法

(0)