def _heuristic_element_order(samples):
'''
Finds an order of elements that heuristically facilitates vine
modelling. For this purpose, Kendall's tau is calculated between
samples of pairs of elements and elements are scored according to the
sum of absolute Kendall's taus of pairs the elements appear in.
Parameters
----------
samples : array_like
n-by-d matrix of samples where n is the number of samples and d is
the number of marginals.
Returns
-------
order : array_like
Permutation of all element indices reflecting descending scores.
'''
dim = samples.shape[1]
# Score elements according to total absolute Kendall's tau
score = np.zeros(dim)
for i in range(1, dim):
for j in range(i):
tau, _ = kendalltau(samples[:, i], samples[:, j])
score[i] += np.abs(tau)
score[j] += np.abs(tau)
# Get order indices for descending score
order = score.argsort()[::-1]
return order
评论列表
文章目录