def bic(arr1, arr2, arr, i=0, saved={}):
"""Bayes Information Criterion
Notes: In the seminal paper "Speakers, environment and channel change
detection and clustering via the Bayesian Information Criterion" by Chen
and Gopalakrishnan, they use a growing window approach, so it's not
directly comparable when using a fixed sliding window.
In BIC, we can save the first matrix calculations since in growing windows
these keep repeating all the time, and we are saving just one float so
it's also memory efficient and saves a lot of time (Antonio)"""
if i in saved:
c1 = saved[i]
else:
S1 = np.cov(arr1, rowvar=0)
N1 = arr1.shape[0]
c1 = 0.5 * N1 * np.log(det(S1))
saved[i] = c1
S2 = np.cov(arr2, rowvar=0)
N2 = arr2.shape[0]
N = arr.shape[0]
S = np.cov(arr, rowvar=0)
d = 0.5 * N * np.log(det(S)) - c1\
- 0.5 * N2 * np.log(det(S2))
p = arr.shape[1]
corr = args.lambdac * 0.5 * (p + 0.5 * p * (p + 1)) * np.log(N)
d -= corr
return d
spk-change-detection.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录