# Probability density function between -1 and 1?

I'm currently using Gaussian distribution as a mutation operator for my genetic algorithm. However, I only want to obtain values between -1 and 1. I also don't wish to truncate my Gaussian distribution, which leaves me with lots of 1's and -1's.

What type of probability density function can I use to obtain values between -1 and 1, based on a mean value between -1 and 1?

Here's an image for the distribution that I'm looking for with mean values of 0, -0.5, and 0.5:

A beta distribution seems to suit your needs, but you'll have to perform a transformation in order to change its $(0,1)$ (finite) support to $(-1,1)$ support.

Let $X$ be distributed with a beta distribution, then the random variable $Y$ given by the transformation $$Y=(b-a)X+a$$ is beta distributed and the PDF has finite support in $(a,b)$. In your case, $a=-1$ and $b=1$. The PDF of this linear transformation is given by:$$p(Y=y|\alpha,\beta,a,b)=f\left(\frac{y-a}{b-a}\right)\frac{1}{b-a},$$ where $f(x)$ is the PDF of the beta distribution given in the wiki page that I cited, and $\alpha$ and $\beta$ are it's parameters. In your case, with $a=-1$ and $b=1$ we get: $$p(Y=y|\alpha,\beta)=\frac{1}{2}f\left(\frac{y+1}{2}\right).$$

Here is an attempt to further illustrate how to apply Néstor's suggestion (+1, btw) of using the beta distribution.

The beta distribution has two parameters $\alpha$ and $\beta$. These determine the shape of the distribution - it can look like the distributions in your figure, like a box, like a straight line, and so on. The question, then, is which parameters you should use for your distributions. You want to get the right mean and the right shape of the distributions.

If $X\sim \rm Beta(\alpha,\beta)$ then its mean is $\mu=\frac{\alpha}{\alpha+\beta}$. Thus $\beta=\alpha(\mu^{-1}-1)$.

Recall that if $Y=2X-1$ then $E(Y)=2E(X)-1$. If you want your distribution on $[-1,1]$ to have mean $0.5$, then the beta distributed variable $X$ (which is on $[0,1]$) should have mean $\mu=0.75$, since $0.5=2*0.75-1$.

Example: Set $\alpha=5$ (say). Then $\beta=5\cdot(1/0.75-1)=5/3$ yields $X$ with mean $0.75$.

By trying different combinations of $\alpha$ and $\mu$ you can in this way find distributions with the right mean and the right shape. Here are some examples that resemble your figures:

Finally, from the illustration in your question it seems that what you've marked in red is the mode (i.e. the maximum of the density function) and not the mean of the distribution. The mode of the beta distribution is $\frac{\alpha-1}{\alpha+\beta-2}$. Thus, if the mode is $m$, we have $\beta=(\alpha-1)/m-a+2$. Using this, you can find distributions with the right shape and the right mode with experiments analogous to those above.

• +1 top quality answers, this stackexchange site is awesome :D – daniloquio Jul 10 '12 at 20:57
• (+1) Nice illustration of the suggestion! – Néstor Jul 10 '12 at 21:14
• (+1) Wait, I hadn't upvoted this? A couple side notes: If you like one-character edits, you can change $*$ to $\cdot$ in one place. Also, it seems you implicitly restrict the parameter space of interest to $\{(\alpha,\beta):\alpha > 1, \beta > 1\}$, which makes sense in the OP's case. :) – cardinal Jul 18 '12 at 12:38
• @cardinal: Apparently not - what took you so long?! ;) You're quite right about the restrictions (but then again, it doesn't make much sense to talk about the mode unless it exists). I may edit this if I feel that I want to add something more as well (keeping in line with the recent discussions on meta :) – MånsT Jul 18 '12 at 12:45