示例#1
0
    def sample(self, i):
        s = self.data[i]
        ss = self.dd[i]
        
        probs = []
        for t in range(self.K):
            prior = math.log(self.counts[t])
            
            ll = self.mvNormalLL(s, ss, 1, self.mu[t], self.precision[t], self.logdet[t])
            probs.append(prior + ll)
        if self.K < self.con.pruningfactor:
            prior = self.con.logalpha

            ll = self.integrated[i]     
            probs.append(prior + ll)
        normed = logNormalize(probs)
        return sampleIndex(normed)    
示例#2
0
    def sample(self, i):
        probs = []
        for t in range(self.K):
            prior = math.log(self.counts[t])
            ll = self.posteriorPredictive(set([i]), self.data[i], self.dd[i], t)
            indices = self.getIndices(t)
            suffprior = np.zeros(len(indices))
            for j, ind in enumerate(indices):
                suffprior[j] = self.prior[i, ind]
            avgprior = np.log(suffprior.sum() / len(indices))
            
            probs.append(prior + avgprior + ll)
        if self.K < self.con.pruningfactor:
            prior = self.con.logalpha

            ll = self.integrated[i]     
            probs.append(prior + ll)
        normed = logNormalize(probs)
        return sampleIndex(normed)