def multinomial(Tot, vec):
    #Computes the special multinomial function \binom{d}{\alpha} defined in the paper
    if np.sum(vec)!=Tot:
        raise(AssertionError("The multinomial is not well defined"))
    else:
        if len(vec)==1: return 1
        else:
            return(binom(Tot,vec[0])*multinomial(Tot-vec[0],np.delete(vec,[0])))
Ejemplo n.º 2
0
def bernstein(n, k):
    """Bernstein polynomial."""
    from scipy.special._ufuncs import binom

    coeff = binom(n, k)

    def _bpoly(x):
        return coeff * x**k * (1 - x)**(n - k)

    return _bpoly
Ejemplo n.º 3
0
def P(n, k):
    return binom(2 ** k, n) * 0.25 ** n * 0.75 ** (2 ** k - n)