Skip to main content
Post Made Community Wiki by whuber
Source Link
agenis
  • 267
  • 3
  • 19

If you are looking for something very simple, with a central plateau and the sides of a triangle distribution, you can for instance combine N triangle distributions, N depending on the desired ratio between the plateau and the descent. Why triangles, because their sampling functions already exist in most languages. You randomly sort from one of them.

In R that would give:

library(triangle)
rplateau = function(n=1){
  replicate(n, switch(sample(1:3, 1), rtriangle(1, 0, 2), rtriangle(1, 1, 3), rtriangle(1, 2, 4)))
}
hist(rplateau(1E5), breaks=200)

enter image description here enter image description here