def rho2beta(rho, returnSize='K+1'):
''' Calculate probability for all components including remainder.
Returns
--------
beta : 1D array, size equal to 'K' or 'K+1', depending on returnSize
beta[k] := probability of topic k
'''
rho = np.asarray(rho, dtype=np.float64)
if returnSize == 'K':
beta = rho.copy()
beta[1:] *= np.cumprod(1 - rho[:-1])
else:
beta = np.append(rho, 1.0)
beta[1:] *= np.cumprod(1.0 - rho)
return beta
评论列表
文章目录