MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / sample_cluster_identity

Function sample_cluster_identity

bayesian_ml/4/npbgmm.py:41–51  ·  view source on GitHub ↗
(phi)

Source from the content-addressed store, hash-verified

39
40
41def sample_cluster_identity(phi):
42 # phi is a dictionary: cluster index -> probability of that cluster
43 # print "dictionary sample from:", phi
44 p = np.random.random()
45 cumulative = 0
46 for j, q in phi.iteritems():
47 cumulative += q
48 if p < cumulative:
49 return j
50 # print "cumulative:", cumulative
51 assert(False) # should never get here because cumulative = 1 by now
52
53
54def sample_from_prior(c0, m0, a0, B0):

Callers 1

gmmFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected