_matutils – Compiled extension for math utils¶
-
gensim._matutils.digamma¶ Digamma function for positive floats, using
_digamma().- Parameters
x (float) – Positive value.
- Returns
Digamma(x).
- Return type
float
-
gensim._matutils.dirichlet_expectation(alpha)¶ Expected value of log(theta) where theta is drawn from a Dirichlet distribution. Using
dirichlet_expectation_1d()ordirichlet_expectation_2d().- Parameters
alpha (numpy.ndarray) – Dirichlet parameter 2d matrix or 1d vector, if 2d - each row is treated as a separate parameter vector, supports float16, float32 and float64.
- Returns
Log of expected values, dimension same as alpha.ndim.
- Return type
numpy.ndarray
-
gensim._matutils.dirichlet_expectation_1d(alpha)¶ Expected value of log(theta) where theta is drawn from a Dirichlet distribution. Using
_dirichlet_expectation_1d().- Parameters
alpha (numpy.ndarray) – Dirichlet parameter 1d vector, supports float16, float32 and float64.
- Returns
Log of expected values, 1d vector.
- Return type
numpy.ndarray
-
gensim._matutils.dirichlet_expectation_2d(alpha)¶ Expected value of log(theta) where theta is drawn from a Dirichlet distribution. Using
_dirichlet_expectation_2d().- Parameters
alpha (numpy.ndarray) – Dirichlet parameter 2d matrix, each row is treated as a separate parameter vector, supports float16, float32 and float64.
- Returns
Log of expected values, 2d matrix.
- Return type
numpy.ndarray
-
gensim._matutils.logsumexp(x)¶ Log of sum of exponentials, using
_logsumexp_2d().- Parameters
x (numpy.ndarray) – Input 2d matrix, supports float16, float32 and float64.
- Returns
log of sum of exponentials of elements in x.
- Return type
float
Warning
By performance reasons, doesn’t support NaNs or 1d, 3d, etc arrays like
scipy.special.logsumexp().
-
gensim._matutils.mean_absolute_difference(a, b)¶ Mean absolute difference between two arrays, using
_mean_absolute_difference().- Parameters
a (numpy.ndarray) – Input 1d array, supports float16, float32 and float64.
b (numpy.ndarray) – Input 1d array, supports float16, float32 and float64.
- Returns
mean(abs(a - b)).
- Return type
float
