1
$\begingroup$

How can I generate n random numbers from (a, b) interval such that these numbers are densely concentrated around min and max and getting progressively sparse in the middle.

$\endgroup$
  • $\begingroup$ Could you define more precisely what do you mean by "densely concentrated around min and max and getting progressively sparse in the middle"? It can understood differently by different people. I guess beta distribution with parameters <1 can work for you, but this needs clarification. $\endgroup$ – Tim Mar 22 '18 at 8:49
  • $\begingroup$ Welcome to Cross Validated. Some related questions have already been answered, e.g. stats.stackexchange.com/questions/324878/… try searching this site and if your question is more specific than the questions here please update which specific part you are asking about. $\endgroup$ – Martin Modrák Mar 22 '18 at 8:50
3
$\begingroup$

Use a with both parameters equal and less than one. For instance:

shape1 <- 1/4
shape2 <- 1/4
set.seed(123)
hist(rbeta(1e4,shape1,shape2))

beta histogram

This will give you numbers between 0 and 1. Shift and scale these to match your desired $a$ and $b$.

The NIST Gallery of Distributions is often useful to find a distribution

| cite | improve this answer | |
$\endgroup$

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.