コード例 #1
0
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]
コード例 #2
0
ファイル: true_vs_mean_field.py プロジェクト: poneill/amic
 def E(xs):
     """Compute energy function for P,unnormalized"""
     ff = falling_fac(q,sum(xs))
     if ff == 0:
         return 1000
     else:
         return log(ff) + sum(ep*x for (x,ep) in zip(xs,eps))
コード例 #3
0
 def f(i,j):
     if i == j:
         return 1
     elif j > i:
         return ki**(j-i)*falling_fac(q-i,j-i)*(-1)**j*(-1)**i
     else:
         return 0
コード例 #4
0
 def log_dprop_direct(config,old_config):
     occupancy = sum(config)
     poses = positions(config)
     return log(falling_fac(copy_number,occupancy)*product(exp(-beta*eps[i]*config[i])
                                                           for i in range(config_len)))
コード例 #5
0
ファイル: transfer_matrix.py プロジェクト: poneill/amic
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))
コード例 #6
0
ファイル: transfer_matrix.py プロジェクト: poneill/amic
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)))
コード例 #7
0
ファイル: lift_rsa_to_gq.py プロジェクト: poneill/amic
 def Pstar(xs):
     """Compute probability of config under Gq model, up to Z"""
     weight = falling_fac(q,len([x for x in xs if x > 0]))
     return weight * product([ks[x] for x in xs])