Пример #1
0
func (m *MoM) Posterior() float64 {
	posterior := util.LbetaCounts(m.Alpha, m.Topics)
	for z := 0; z < m.T; z++ {
		posterior += util.LbetaCounts(m.Beta, m.TopicWords[z])
	}
	return posterior
}
Пример #2
0
// Posterior computes an expression proportional to the posterior probabilty.
func (l *LDA) Posterior() float64 {
	result := 0.0
	for d := 0; d < l.M; d++ {
		result += util.LbetaCounts(l.Alpha, l.DocTopics[d])
	}
	for z := 0; z < l.T; z++ {
		result += util.LbetaCounts(l.Beta, l.TopicWords[z])
	}
	return result
}
Пример #3
0
func (i *ITM) Posterior() float64 {
	result := 0.0
	for z := 0; z < i.T; z++ {
		result += util.LbetaCounts(i.Beta, i.TopicConstraints[z])
		for c := 0; c < i.V; c++ {
			if s := len(i.ConstraintWords[c]); s > 1 {
				tc := make([]int, 0, s)
				for v := range i.ConstraintWords[c] {
					tc = append(tc, i.TopicConstraintWords[z][c][v])
				}
				result += util.LbetaCounts(i.Eta, tc)
			}
		}
	}
	for d := 0; d < i.M; d++ {
		result += util.LbetaCounts(i.Alpha, i.DocTopics[d])
	}
	return result
}
Пример #4
0
func (m *DPMoM) Posterior() float64 {
	posterior := 0.0
	for z, used := range m.Used {
		posterior += math.Log(float64(m.Topics[z]))
		if used {
			posterior += util.LbetaCounts(m.Beta, m.TopicWords[z])
		}
	}
	return posterior
}