I just need to generate random numbers in $[0,1]$ which are more dense at the end points. I first thought of generating two sets of numbers from $N(0,1)$ and $N(1,1)$, and then using those. But that isn't working that well. Is there a better way?
Any command in SAGE will be most helpful! Thank you in advance!
Five simple contenders:
1. Arc-Sine(0,1) distribution
Draw your pseudo-random samples from an Arc-Sine(0,1) distribution, with pdf:
$$ f(x) = \frac{1}{\pi \sqrt{1-x} \sqrt{x}}$$
which is nested by a $Beta(\frac12,\frac12)$ distribution. Here is a plot of the pdf:
2. Semi-circle (up)
$$f(x) = 2 - \frac{8 \sqrt{(1-x)x}}{\pi}$$
3. U-quadratic
$$f(x) = 3(1-2x)^2$$
4. V distribution
$$f(x) = 4 \omega \left|x-\frac12\right| + 1-\omega$$
where $0\le \omega \le 1$
5. sine of a Normal rv
Let $X$~$N(0,1)$. Then
$$\frac{sin(X)+1}{2}$$
has your desired U-shape.
Unlike the other contenders, this one does not have a convenient closed-form solution for the pdf, ... but it is incredibly easy to generate. Just generate some standard Normals, apply the sin function, add 1, and divide it all by 2. Here is what the resulting empirical pdf looks like: