コード例 #1
0
def logtildegamma(G, Z, X, supp, w, G_mu, G_Sigma, eta):
    prob = gv.sigmoid(w + gv.logit(Z))
    llh = np.sum(supp * X * clog(prob)) + np.sum(supp *
                                                 (1 - X) * clog(1 - prob))
    prior = logpdf(G, G_mu, G_Sigma)
    #print llh, prior
    return llh + prior
コード例 #2
0
 def fun(w0):
     return gv.sigmoid(w0 +
                       gv.logit(Zs_ok[..., f])).mean() - Xbar[l0,
                                                              l1, f]
コード例 #3
0
        if 0:
            l0 = l1 = 4
            f = 10

            def fun(w0):
                return gv.sigmoid(w0 +
                                  gv.logit(Zs_ok[..., f])).mean() - Xbar[l0,
                                                                         l1, f]

            #import IPython
            #IPython.embed()

            w[l0, l1, f] = find_zero(fun, l=-6, u=6, depth=15)

        LZ = gv.logit(Zs_ok.clip(EPS, 1 - EPS))

        if 0 and loop == 0:
            import IPython
            IPython.embed()

        BINS = 50
        LZ_counts = np.zeros((F, BINS))
        LZ_values = np.zeros((F, BINS))
        for f in xrange(F):
            ret = np.histogram(LZ[..., f], BINS)
            LZ_counts[f] = ret[0]
            LZ_values[f] = (ret[1][1:] + ret[1][:-1]) / 2

        print LZ_counts[0]
        print LZ_values[0]
コード例 #4
0
 def clogit(x):
     return gv.logit(gv.bclip(x, 0.025))
コード例 #5
0
def logtildegamma(G, Z, X, supp, w, G_mu, G_Sigma, eta):
    prob = gv.sigmoid(w + gv.logit(Z))
    llh = np.sum(supp * X * clog(prob)) + np.sum(supp * (1 - X) * clog(1 - prob))
    prior = logpdf(G, G_mu, G_Sigma)
    #print llh, prior
    return llh + prior
コード例 #6
0
 def fun(w0):
     return gv.sigmoid(w0 + gv.logit(Zs_ok[...,f])).mean() - Xbar[l0,l1,f]
コード例 #7
0
                    w[l0,l1,f] = find_zero(fun, l=-6, u=6, depth=15)

        if 0:
            l0 = l1 = 4
            f = 10

            def fun(w0):
                return gv.sigmoid(w0 + gv.logit(Zs_ok[...,f])).mean() - Xbar[l0,l1,f]

            #import IPython
            #IPython.embed()

            w[l0,l1,f] = find_zero(fun, l=-6, u=6, depth=15)


        LZ = gv.logit(Zs_ok.clip(EPS, 1-EPS))

        
        if 0 and loop == 0:
            import IPython
            IPython.embed()

        BINS = 50
        LZ_counts = np.zeros((F, BINS))
        LZ_values = np.zeros((F, BINS))
        for f in xrange(F):
            ret = np.histogram(LZ[...,f], BINS)
            LZ_counts[f] = ret[0]
            LZ_values[f] = (ret[1][1:] + ret[1][:-1])/2

        print LZ_counts[0]