curve.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:pyhiro 作者: wanweiwei07 项目源码 文件源码
def binomial(n):
    '''
    Return all binomial coefficents for a given order.

    For n > 5, scipy.special.binom is used, below we hardcode
    to avoid the scipy.special dependancy. 
    '''
    if   n == 1: return [1,1]
    elif n == 2: return [1,2,1]
    elif n == 3: return [1,3,3,1]
    elif n == 4: return [1,4,6,4,1]
    elif n == 5: return [1,5,10,10,5,1]
    else:
        from scipy.special import binom
        return binom(n,np.arange(n+1))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号