# Generate a random set of numbers with fixed sum and desired means and variances?

The Dirichlet distribution allows you to generate a sample of numbers $x_i$ with a prescribed sum, say $\sum_i x_i = 1$. Moreover, the parameters $\alpha$ allow some degree of control on the means of the individual $x_i$. I also want to generate random non-negative numbers $x_i$ with sum $\sum_i x_i = 1$. But I would like to have an additional parameter to also control somehow the variances of the $x_i$ around their means. Is there a generalization of the Dirichlet distribution in this direction?

Multivariate logit-normal distribution can be considered as a generalization of the Dirichlet distribution that you have in mind. It is parametrized by a vector of $D-1$ means $\boldsymbol{\mu}$ for $D$-dimensional vector $\mathbf{x}$ and covariance matrix $\boldsymbol{\Sigma}$,

$$f_X( \mathbf{x}; \boldsymbol{\mu} , \boldsymbol{\Sigma} ) = \frac{1}{ | 2 \pi \boldsymbol{\Sigma} |^\frac{1}{2} } \, \frac{1}{ \prod\limits_{i=1}^D x_i } \, e^{- \frac{1}{2} \left\{ \log \left( \frac{ \mathbf{x}_{-D} }{ x_D } \right) - \boldsymbol{\mu} \right\}^\top \boldsymbol{\Sigma}^{-1} \left\{ \log \left( \frac{ \mathbf{x}_{-D} }{ x_D } \right) - \boldsymbol{\mu} \right\} }$$

Since it is defined as a logistic transformation of multivariate normal distribution $\mathbf{y} \sim \mathcal{N} \left( \boldsymbol{\mu} , \boldsymbol{\Sigma} \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]^\top$$

the random generation is straightforward since you need only to take samples from multivariate normal distribution and transform them.

Wikipedia (https://en.wikipedia.org/wiki/Dirichlet_distribution) describes the means and variances of the n individual x's in terms of the n exponenents (written as a's) and their sum. The means will not be changed if all the a's are multiplied by some constant b. However the variances will change, at least somewhat.

More, but more complicated, control of both would be provided by giving each "a" its own "b".

Depending on exactly what you are trying to achieve, you might write a set of simultaneous for the means and variances in terms of a's and b's that could be inverted to give a prescription for the later in terms of the former. These equations might require a nonlinear numeric solver. (But note that multiplying the a's and b's would not be the only option for combining the two.)

However, because of the constraints built into this distribution, it is not clear how much flexibility will be available in making independent adjustments to the means and variances. You would have to experiment.

• If you multiply each "a" by its own "b", and require that the means are fixed, necessarily all the "b"'s are equal. – becko Aug 29 '17 at 15:38