Ejemplo n.º 1
0
    def _updateH(self):
        self.rhoh = self.ah + self.M.sum(3)
        self.tauh[:,:,:] = (self.bh + (self.Eg[:,sp.newaxis,sp.newaxis] * self.Ew * self.Et[:,sp.newaxis,:]).sum(1))[:,:,sp.newaxis]
        self.Eh = Gamma(self.rhoh, self.tauh).expectation()

        print 'Eh:'
        print self.Eh
Ejemplo n.º 2
0
    def _updateG(self):
        Ew = sp.transpose(self.Ew, (0,2,1))
        self.rhog = self.alphag / self.Kg + self.M.sum((1,2,3))
        self.taug = self.alphag * self.cg + (self.Eh[:,:,:,sp.newaxis] * Ew[:,:,sp.newaxis,:] * self.Et[:,:,sp.newaxis,sp.newaxis]).sum((1,2,3))
        self.Eg = Gamma(self.rhog, self.taug).expectation()

        print 'Eg:'
        print self.Eg
Ejemplo n.º 3
0
    def _updateW(self):
        self.rhow = self.aw + self.M.sum(2)
        self.rhow = sp.transpose(self.rhow, (0,2,1))
        self.tauw[:,:,:] = (self.bw + (self.Eg[:,sp.newaxis,sp.newaxis] * self.Eh * self.Et[:,:,sp.newaxis]).sum(2))[:,sp.newaxis,:]

        self.Ew = Gamma(self.rhow, self.tauw).expectation()

        # print 'rhow:'
        # print self.rhow
        # print 'tauw:'
        # print self.tauw
        print 'Ew:'
        print self.Ew
Ejemplo n.º 4
0
    def _updateG_brute(self):
        self.rhog[:] = self.alphag
        for g in xrange(self.Kg):
            for j in xrange(self.Kt):
                for t in xrange(self.nT):
                    for f in xrange(self.nF):
                        self.rhog[g] += self.M[g,j,t,f]

        self.taug[:] = self.alphag / self.cg
        for g in xrange(self.Kg):
            for j in xrange(self.Kt):
                for t in xrange(self.nT):
                    for f in xrange(self.nF):
                        self.taug[g] += self.Eh[g,j,t] * self.Ew[g,f,j] * self.Et[g,j]

        self.Eg = Gamma(self.rhog, self.taug).expectation()
Ejemplo n.º 5
0
    def _updateTheta_brute(self):
        self.rhot[:,:] = self.alphat
        for g in xrange(self.Kg):
            for j in xrange(self.Kt):
                for t in xrange(self.nT):
                    for f in xrange(self.nF):
                        self.rhot[g,j] += self.M[g,j,t,f]

        self.taut[:,:] = self.alphat / self.Kt
        for g in xrange(self.Kg):
            for j in xrange(self.Kt):
                for t in xrange(self.nT):
                    for f in xrange(self.nF):
                        self.taut[g,j] += self.Eg[g] * self.Eh[g,j,t] * self.Ew[g,f,j]

        self.Et = Gamma(self.rhot, self.taut).expectation()
Ejemplo n.º 6
0
    def _updateH_brute(self):
        self.rhoh[:,:,:] = self.ah
        for g in xrange(self.Kg):
            for j in xrange(self.Kt):
                for t in xrange(self.nT):
                    for f in xrange(self.nF):
                        self.rhoh[g,j,t] += self.M[g,j,t,f]

        self.tauh[:,:,:] = self.bh
        for g in xrange(self.Kg):
            for j in xrange(self.Kt):
                for t in xrange(self.nT):
                    for f in xrange(self.nF):
                        self.tauh[g,j,t] += self.Eg[g] * self.Ew[g,f,j] * self.Et[g,j]

        self.Eh = Gamma(self.rhoh, self.tauh).expectation()
Ejemplo n.º 7
0
    def _updateW_brute(self):
        self.rhow[:,:,:] = self.aw
        for g in xrange(self.Kg):
            for j in xrange(self.Kt):
                for t in xrange(self.nT):
                    for f in xrange(self.nF):
                        self.rhow[g,f,j] += self.M[g,j,t,f]

        self.tauw[:,:,:] = self.bw
        for g in xrange(self.Kg):
            for j in xrange(self.Kt):
                for t in xrange(self.nT):
                    for f in xrange(self.nF):
                        self.tauw[g,f,j] += self.Eg[g] * self.Eh[g,j,t] * self.Et[g,j]

        self.Ew = Gamma(self.rhow, self.tauw).expectation()
Ejemplo n.º 8
0
    def _updateTheta(self):
        # Ew = sp.transpose(self.Ew, (0,2,1))

        # self.rhot = self.alphat + self.M.sum((2,3))
        # self.taut = self.alphat / self.ct + (self.Eh[:,:,:,sp.newaxis] * Ew[:,:,sp.newaxis,:] * self.Et[:,:,sp.newaxis,sp.newaxis]).sum((2,3))
        self.rhot = self.alphat / self.Kt + self.M.sum( (2,3) )

        for g in xrange(self.Kg):
            Eh_g = self.Eh[g]
            Ew_g = self.Ew[g].T
            self.taut[g,:] = self.alphat * self.ct + (Eh_g[:,:,sp.newaxis] * Ew_g[:,sp.newaxis,:]).sum((1,2))
            # self.taut[g,:] = (self.Eg[g] * Eh_g[:,:,sp.newaxis] * Ew_g[:,sp.newaxis,:]).sum((1,2))

        self.Et = Gamma(self.rhot, self.taut).expectation()

        print 'Et:'
        print self.Et
Ejemplo n.º 9
0
 def _compute_expectations(self):
     self.Ew = Gamma(self.rhow, self.tauw).expectation()
     self.Eh = Gamma(self.rhoh, self.tauh).expectation()
     self.Et = Gamma(self.rhot, self.taut).expectation()
     self.Eg = Gamma(self.rhog, self.taug).expectation()