示例#1
0
def outer_small(p1, fac_array, Ai, spi, posi, negi, likes_now):
    N = fac_array.shape[1]
    
    # For each sample from the posterior of r
    for j in xrange(N):
        # Compute actual PfPR[A[i]]
        p2 = fac_array[:,j][Ai]

        # Record likelihood
        # k1=np.add.outer(np.log(p1),np.log(p2))
        k1 = np.log(p1)*spi + np.dot(posi,np.log(p2))

        # k2 = log(1.-np.outer(p1,p2))
        k2 = cfh(p1,p2,negi)
        # k1 = np.dot(k1,posi)
        # k2 = np.dot(k2,negi)

        likes_now[j,:] = k1 + k2
        
    # Average log-likelihoods.
    return np.apply_along_axis(logsum,0,likes_now) - log(N)#(mean(likes_now,axis=0))
def outer_small(p1, fac_array, Ai, spi, posi, negi, likes_now):
    N = fac_array.shape[1]

    # For each sample from the posterior of r
    for j in xrange(N):
        # Compute actual PfPR[A[i]]
        p2 = fac_array[:, j][Ai]

        # Record likelihood
        # k1=np.add.outer(np.log(p1),np.log(p2))
        k1 = np.log(p1) * spi + np.dot(posi, np.log(p2))

        # k2 = log(1.-np.outer(p1,p2))
        k2 = cfh(p1, p2, negi)
        # k1 = np.dot(k1,posi)
        # k2 = np.dot(k2,negi)

        likes_now[j, :] = k1 + k2

    # Average log-likelihoods.
    return np.apply_along_axis(logsum, 0, likes_now) - log(
        N)  #(mean(likes_now,axis=0))
示例#3
0
 def this_fun(x, p2=p2, p3=p3,negi=negi, posi=posi, Ai=Ai):
     p1 = np.log(invlogit(x))
     return p1*spi + p3 + cfh(p1,p2,negi)
 def this_fun(x, p2=p2, p3=p3, negi=negi, posi=posi, Ai=Ai):
     p1 = np.log(invlogit(x))
     return p1 * spi + p3 + cfh(p1, p2, negi)