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

Function sample_from_X

bayesian_ml/4/npbgmm.py:62–72  ·  view source on GitHub ↗
(X, m0, c0, a0, B0)

Source from the content-addressed store, hash-verified

60
61# samples mu, sigma from P(mu, sigma | X)
62def sample_from_X(X, m0, c0, a0, B0):
63 N = len(X)
64 s = float(N)
65 m = (c0 / (s + c0))*m0 + (1 / (s + c0))*X.sum(axis=0)
66 c = s + c0
67 a = s + a0
68 meanX = X.mean(axis=0)
69 B = (s / (a0*s + 1)) * np.outer(meanX - m0, meanX - m0) + B0
70 for i in xrange(N):
71 B += np.outer(X[i] - meanX, X[i] - meanX)
72 return sample_from_prior(c, m, a, B)
73
74
75def gmm(X, T=500):

Callers 1

gmmFunction · 0.85

Calls 1

sample_from_priorFunction · 0.85

Tested by

no test coverage detected