2
$\begingroup$

I'm trying to generate a text document using reverse "Correlated Topic Models", which is an advanced version of LDA (Latent Dirichlet Allocation). In this version the topics are generated over a multinomial distribution with a Logistic-Normal prior. This allows adding correlation between topics through the covariance matrix.

Can anyone please help me simulate values from a multivariate Logistic-Normal distirubtion, i.e. given input parameters myu, sigma (mean vector, and covariance matrix respectively), the result is a distribution over topics.

$\endgroup$
3
$\begingroup$

Unfortunately, scipy.stats doesn't provide the logistic normal distribution. However, you could draw random samples from a multivariate normal distribution (e.g. using numpy) and transform them with a logistic transformation to simulate samples drawn from the logistic-normal distribution.

Let's assume your probability vectors are $D=3$ dimensional.

import numpy as np

# draw from multivariate random distribution of dimension D-1 = 2
mean = (1, 2)
cov = [[1, 0], [0, 1]]
y = np.random.multivariate_normal(mean, cov)

Now (as you can read here), you can transform your normally distributed sample $y \in \mathcal{S}^{D-1}$ to a logistic-normally distributed sample $x \in \mathcal{S}^{D}$:

$$ \mathbf{y} = \left[ \log \left( \frac{ x_1 }{ x_D } \right) , \dots , \log \left( \frac{ x_{D-1} }{ x_D } \right) \right] $$

$$ \mathbf{x} = \left[ \frac{ e^{ y_1 } }{ 1 + \sum_{i=1}^{D-1} e^{ y_i } } , \dots , \frac{ e^{ y_{D-1} } }{ 1 + \sum_{i=1}^{D-1} e^{ y_i } } , \frac{ 1 }{ 1 + \sum_{i=1}^{D-1} e^{ y_i } } \right] $$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.