To generate samples with multivariate t-distribution I use this function:
def multivariatet(mu,Sigma,N,M):
'''
Output:
Produce M samples of d-dimensional multivariate t distribution
Input:
mu = mean (d dimensional numpy array or scalar)
Sigma = scale matrix (dxd numpy array)
N = degrees of freedom
M = # of samples to produce
'''
d = len(Sigma)
g = np.tile(np.random.gamma(N/2.,2./N,M),(d,1)).T
Z = np.random.multivariate_normal(np.zeros(d),Sigma,M)
return mu + Z/np.sqrt(g)
but what I am looking for now is the multivariate student t-distribution it self so I can calculate the density of elements where dimension > 1
.
That will be something like stats.t.pdf(x, df, loc, scale)
of the package scipy but in multi-dimensional space.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…