Generate Random Numbers with Probabilistic Distribution

前端 未结 4 1842
再見小時候
再見小時候 2020-12-08 08:32

Ok, so here\'s my problem. We are looking at purchasing a data set from a company to augment our existing data set. For the purposes of this question, let\'s say that this

4条回答
  •  时光取名叫无心
    2020-12-08 09:34

    The easiest (but not very efficient) way to generate random numbers that follow a given distribution is a technique called Von Neumann Rejection.

    The simple explination of the technique is this. Create a box that completely encloses your distribution. (lets call your distribution f) Then pick a random point (x,y) in the box. If y < f(x), then use x as a random number. If y > f(x), then discard both x and y and pick another point. Continue until you have a sufficient amount of values to use. The values of x that you don't reject will be distributed according to f.

提交回复
热议问题