def simple_multivariate_t_distribution(self, x, mu, sigma, df, d):
'''
Multivariate t-student density:
output:
the density of the given element
input:
x = parameter (d dimensional numpy array or scalar)
mu = mean (d dimensional numpy array or scalar)
Sigma = scale matrix (dxd numpy array)
df = degrees of freedom
d: dimension
'''
num = special.gamma((df + d)/2)
xSigma = np.dot((x - mu), np.linalg.inv(sigma))
xSigma = np.array([xSigma[i, i] for i in range(self.K)])
denom = special.gamma(df / 2) * np.power(df * np.pi, d / 2.0)\
* np.power(np.linalg.det(sigma), 1 / 2.0)\
* np.power(1 + (1. / df)\
* np.sum(xSigma * (x - mu), axis=1), (d + df) / 2)
result = num / denom
return result
评论列表
文章目录