def occupancies_ref(ks,q): def remove(xs,x): xs_new = xs[:] xs_new.remove(x) return xs_new Z = float(sum(falling_fac(q,n)*esp(ks,n) for n in range(q+1))) print "Z:",Z return [(q*k*sum(show(falling_fac(q-1,n)*esp(remove(ks,k),n)) for n in range(q)))/Z for k in ks]
def omega(N,q): assert 0 <= q <= N ks = [make_k(i) for i in range(1,N+1)] return sum(int(fac(q)/fac(q-i))*esp(ks,i) for i in range(q+1))
def step_n(om,nplus1,q): ks = [make_k(i) for i in range(1,nplus1 + 1)] k = make_k(nplus1) return om*(1+k) - q*esp(ks,nplus1)
def ncp(ps,n): return fac(n)*esp(ps,n)/1.0
def occupancy_check(ks,q): """Compute occupancy explicity, as a check""" return sum(j*falling_fac(q,j)*esp(ks,j) for j in range(q+1))/float(partition_check(ks,q))
def partition_check(ks,q): """Compute partition function explicity, as a check""" print "G,q:",len(ks),q return sum(falling_fac(q,j)*esp(ks,j) for j in verbose_gen(range(q+1)))