The Dirichlet distribution contains values that are bounded $[0,1]\in \mathbb{R}$ and sum to $1$. Is there a parametric distribution or similar method whose values do the same but reach as low as $-1$?

Parallel discussion of the code

  • 6
    $\begingroup$ Maybe you should explain your underlying problem a bit more because currently your question is abstract (leading to an infinite possibilities) and it is unclear what the actual problem is or how specific you want it. $\endgroup$ – Sextus Empiricus Sep 15 '20 at 6:35
  • 1
    $\begingroup$ 1: It is a bit tricky to gravitate towards a scaled Dirichlet. The Dirichlet distribution is just what you proposed yourselve in your question and what others have copied (but why do you propose it?). Furthermore, as I showed in my answer, a scaled Dirichlet distribution only works when the dimension is 3. It is also tricky because a question with so little specifications is troubling and not a good standard. $\endgroup$ – Sextus Empiricus Sep 15 '20 at 16:48
  • 3
    $\begingroup$ 2: If other people with a similar problem stumble on this question then they should not be automatically satisfied with the answers. For many problems you can not just pick any out of many distributions. Or at least it is not a good practice. You should have some argument/background/information how and where the distribution is applied (what should it do? what should it model?). You can not go solve a problem by asking people what $\alpha$ you should use without giving any information what you need it for. $\endgroup$ – Sextus Empiricus Sep 15 '20 at 16:49
  • 1
    $\begingroup$ You write "...values do the same but reach as low as -1". You probably meant with 'the same' the sum up to 1, but it might be that you meant the Dirichlet distribution. .....Anyway, it doesn't matter who came up with it first. A scaled Dirichlet distribution does not always sum up to 1 (so it is not a correct/general answer)..... But you can, of course, always define a continuous distribution, or any other distribution, on the plane with normal vector $x_1+x_2+...+x_n = 1$, without scaling the Dirichlet distribution, but choosing any function. $\endgroup$ – Sextus Empiricus Sep 15 '20 at 22:22
  • 1
    $\begingroup$ a scaled Dirichlet doesn't always sum up to 1. $\endgroup$ – Sextus Empiricus Sep 16 '20 at 5:22

Scaling a Dirichlet distribution

If you want a variable that is distributed like a Dirichlet distributed variable but with a different range then you can scale and shift (transform the variable). This is effectively rescaling the axes.

To get from $[0,1]$ to $[-1,1]$ you can multiply by 2 and subtract 1. That is, your new variable $Y$ can be based on a regular Dirichlet distributed variable $X$ by the transformation

$$Y = 2X -1$$

(Where the transformation is done for each of the components, that is for every $y_i$ you compute $y_i = 2x_i-1$)

The probability density function will scale similarly but with an additional scaling factor (the density is less when you spread out over a larger range).

So the regular Dirichlet distributed variable $X$ has the density distribution $f_X$:

$$f_X(\mathbf{x}) = \frac{1}{B(\boldsymbol{\alpha})} \prod_{i=1}^K x_i^{\alpha_i-1}$$

and the variable $Y = 2X-1$ has this density distribution $f_Y$:

$$f_Y(\mathbf{y}) = \frac{1}{2^K} f_X \left(\frac{\mathbf{y}+1}{2}\right) = \frac{1}{B(\boldsymbol{\alpha})2^K} \prod_{i=1}^K \left(\frac{y_i+1}{2}\right)^{\alpha_i-1}$$

where $B(\mathbf{\boldsymbol{\alpha}}) =\prod_{i=1}^K \frac{\Gamma(\alpha_i)}{\Gamma(\sum_{i=1}^K \alpha_i)}$

So you do not need to change anything to $\alpha$. The transformation only requires scaling and shifting the axes (which also includes a scaling of the density by a factor $1/2^K$).

Whatever $\alpha$ needs to be will depend on your application.

When there is a constraint

Is there a statistical distribution whose values are bounded [−1,1] and sum to 1?

Note: This transformation by scaling the axis is not always generally possible in case of your additional constraint.

Your additional condition requires $$\sum_{i=1}^n y_i = \sum_{i=1}^n (a + b x_i) = an + b \sum_{i=1}^n x_i = 1$$ and this only holds when $n = \frac{1-b}{a}$. With our straightforward transformation $a=-1$ and $b=2$ it does not hold. We need to use instead $a=1$ and $b=-2$, and then it will only work for a Dirichlet distribution with $n=3$.

The figure below shows this


The red plane is the domain of the 'regular' Dirichlet distribution.

The green plane is when you apply the transformation $y_i = 2x_i -1$, but then you do not get anymore that the variables sum up to 1. Instead the variables will sum up to -1.

The blue plane $y_i = 1 - 2 x_i$ will give you a transformation such that the sum is still 1.

A homogeneous distribution

Based on your stackoverflow question it seems that you are not looking for a distribution like the Dirichlet distribution, but you are looking for a homogeneous distribution (a special case of the Dirichlet distribution when all $\alpha_i =1$), where the pdf equals some constant $f(\mathbf{x}) = c$.

You can do this by rejection sampling or by an iterative computation of the coordinates $x_i$ where conditional/marginal distributions $f(x_i|x_1,x_2,\dots,x_{i-1})$ can be derived from rescaled and truncated versions of the Irwin Hall distribution. It is explained in the answer to your stackoverflow question.

  • $\begingroup$ "Do not need to change $\alpha$" assumes i already know what $\alpha$ should be before transformation but i don't. How about this: if I have $P$ variables and i set $\alpha$ equal to a vector of ones of length $P$, do i get what the question asks for? $\endgroup$ – develarist Sep 15 '20 at 14:49
  • $\begingroup$ @develarist any value will do. $\endgroup$ – Sextus Empiricus Sep 15 '20 at 15:43
  • 2
    $\begingroup$ @develarist Indeed a vector of 1s corresponds to a uniform distribution. It is unclear whether this matters. You'd need to explain/specify your question further for these details. $\endgroup$ – Sextus Empiricus Sep 15 '20 at 16:40
  • 1
    $\begingroup$ @develarist "What do we put for $\alpha$?" is a different question than "How can I choose $\alpha$ so that I can draw samples from a uniform Dirichlet distribution?" The second question provides context and information about what you want to achieve, where the first question is unfathomable. This is why each time you asked, people responded with a request for clarification. $\endgroup$ – Sycorax Sep 15 '20 at 19:54
  • 5
    $\begingroup$ @develarist Sounds like an XY problem to me. $\endgroup$ – Sycorax Sep 15 '20 at 20:23

If you really need the variables to sum to one, you could "force it" by dividing by the sum. That is, if $X_1, X_2, \cdots X_n$ are random variables, then the RVs $$Z_i = \frac{X_i}{\sum_{i=1}^n X_i}$$ have the property that $\sum_{i=1}^nZ_i = 1$ (so long as $\sum X_i \neq 0$). This is easy to show.

$$\sum_{j=1}^n Z_j = \sum_{j=1}^n \frac{X_j}{\sum_{i=1}^n X_i} = \frac{1}{\sum_{i=1}^n X_i}\sum_{j=1}^n X_j = 1$$

N <- 10000
x <- 1 - 2*rbeta(N, 3, 3)
z <- x/sum(x)
w <- -1 + 2*(z-min(z))/(max(z) - min(z))

enter image description here

  • $\begingroup$ what distribution is rbeta? $\endgroup$ – develarist Sep 17 '20 at 19:53
  • $\begingroup$ Thats a Beta distribution with support on 0 to 1. I rescaled it to have support on -1 to 1. You can use any distribution appropriately scaled. Worth noting that the Dirichlet is a generalization of the Beta and reduces to the Beta distribution when there are just two random variables ($X$ and $1-X$). $\endgroup$ – knrumsey Sep 18 '20 at 17:46
  • $\begingroup$ does the transformed beta guarantee a sum of 1 as number of variables increases? the transformed Dirichlet was unable to guarantee a sum of 1. $\endgroup$ – develarist Sep 18 '20 at 17:47
  • $\begingroup$ If you define $Z_i = X_i/\sum X_i$, then you can guarantee that $\sum Z_i = 1$. It doesn't matter what distribution the $X_i$ have (as long as $\sum X_i \neq 0$). Please note: This may not be a good idea in some cases. Why is it so important that the variables sum to 1? $\endgroup$ – knrumsey Sep 18 '20 at 17:52
  • $\begingroup$ because 1 represents a 100% allocation of elements that are between -1 and 1. no one can possess more than 100% of something $\endgroup$ – develarist Sep 18 '20 at 18:17

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.