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

Function marginal

bayesian_ml/4/npbgmm.py:19–29  ·  view source on GitHub ↗
(x, c, m, a, B)

Source from the content-addressed store, hash-verified

17
18
19def marginal(x, c, m, a, B):
20 D = len(x)
21 k0 = ( c / (np.pi * (1 + c)) )**(D/2.0)
22 k1top = np.linalg.det(B + (c/(1+c)*np.outer(x - m, x - m)))**(-(a + 1.0)/2.0)
23 k1bot = np.linalg.det(B)**(-a/2.0)
24 k1 = k1top/k1bot
25 k2log = 0
26 for d in xrange(D):
27 k2log += np.log(gamma( (a+1.0)/2.0 + (1.0-d)/2.0 )) - np.log(gamma( a/2.0 + (1.0-d)/2.0 ))
28 k2 = np.exp(k2log)
29 return k0*k1*k2
30
31
32def normalize_phi_hat(phi_hat):

Callers 1

gmmFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected