Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I'm using the function $$\frac{xe^{-x^2}}{\int_0^1 te^{-t^2} \, dt}$$ as a probability density function for generating numbers between 0 and 1. If I want to increase the probability to the zero (crush it to the zero), I have to increase the exponent using something like $xe^{-8x^2}$, but how can I do this if I want to increase the probability value of the function to zero (to crush it to zero in a way to have a pick to the zero)?

share|improve this question
I edited this for readability and grammar, but I have no idea what is being asked. –  Matthew Conroy May 22 '11 at 20:59
If pick to the zero means peak at zero, simply get rid of the factor $x$ and keep the exponential. –  Did May 31 '11 at 22:56

1 Answer 1

Well, one thing you could do is generate you variable, $X$, from a mixture density

$$ p(x) = \lambda p_{1}(x) + (1-\lambda) p_{2}(x) $$

which is a density as long as $\lambda \in (0,1)$ and $p_{1},p_{2}$ are densities. You could choose $p_{1}$ to be the density you specified above and $p_{2}$ to be, for example, a point mass at 0 (e.g. $p_{2}(0) = 1$ and $p_{2}(x) = 0$ for $x \neq 0$). Specifically, the algorithm to sample from $p$ would be:

  1. Generate a bernoulli trial, $Z$, with success probability $\lambda$
  2. If $Z=1$ then generate from $X$ from $p_{1}(x)$. If $Z=0$, then $X=0$.

Of course, a better approach would probably be to use the Beta distribution which is a broad distribution supported on $(0,1)$. Parameter values can be chosen to achieve an arbitrary amount of mass near 0.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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