1

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.

Stephan Kolassa
  • 95,027
  • 13
  • 197
  • 357
  • 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](https://en.wikipedia.org/wiki/Beta_distribution) with parameters <1 can work for you, but this needs clarification. – Tim Mar 22 '18 at 08:49
  • Welcome to Cross Validated. Some related questions have already been answered, e.g. https://stats.stackexchange.com/questions/324878/using-a-random-number-generator-to-draw-samples-from-a-cumulative-distribution-f try searching this site and if your question is more specific than the questions here please update which specific part you are asking about. – Martin Modrák Mar 22 '18 at 08:50

1 Answers1

3

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

Stephan Kolassa
  • 95,027
  • 13
  • 197
  • 357