bayesian_smoothing贝叶斯平滑

# -*- coding: utf-8 -*-

 

import numpy as np

 

def bayesian_smoothing(c, i):

    r = 1.0*c/i

    # print r

    m = np.mean(r)

    v = np.var(r)

    a = (m*(1-m)/v-1)*m

    b = (m*(1-m)/v-1)*(1-m)

 

    c = c+a

    i = i+a+b

    return  1.0*c/i

 

c = np.array([1,2,3])

i = np.array([4,5,6])

print bayesian_smoothing(c, i)

上一篇:js中event的target和currentTarget的区别


下一篇:XDOJ 考勤系统