Java: random integer with non-uniform distribution

前端 未结 11 1601
终归单人心
终归单人心 2020-12-13 12:55

How can I create a random integer n in Java, between 1 and k with a "linear descending distribution", i.e. 1 is

11条回答
  •  时光取名叫无心
    2020-12-13 13:30

    Let me try another answer too, inspired by rlibby. This particular distribution is also the distribution of the smaller of two values chosen uniformly and random from the same range.

提交回复
热议问题