p***o 发帖数: 836 | 1 就是有一个1-5的随机数发生器,如果得到1-7的发生器,忘了怎么做了
(在这个版上看过很简单的方法,不要死循环的) | Q***5 发帖数: 994 | 2 It is not hard to find a method that 'almost surely' stop in finite steps.
I doubt you can find a method that will garentee to finish in some fixed
number (say 1000) of steps. | r**d 发帖数: 1 | 3
I suppose what you mean is given a random number generator that generates 1-
5 with equal prob. (1/5), create another random generator that generates 1-7
with equal prob (1/7).
Assuming the 1-5 generator generates i.i.d. numbers. We will put two numbers
in one group, e.g. from
1, 2, 5, 3, 1, 4, ...
we get
(1, 2), (5, 3), (1, 4), ...
We will have 25 different pairs with equal prob (1/25). We only pick 14
pairs as valid pairs, discard other 11 pairs. We call them pair #1, #2, ...,
#14. When we ge
【在 p***o 的大作中提到】 : 就是有一个1-5的随机数发生器,如果得到1-7的发生器,忘了怎么做了 : (在这个版上看过很简单的方法,不要死循环的)
| l******i 发帖数: 145 | 4 how about the following?
1. generate 2 random numbers from rng5(), say n1 and n2
2. return (35*n2+7*n1-17)/25, integer operation
The formula is from 7*[(n2-1)*5+(n1-1)]/25 + 1
【在 p***o 的大作中提到】 : 就是有一个1-5的随机数发生器,如果得到1-7的发生器,忘了怎么做了 : (在这个版上看过很简单的方法,不要死循环的)
|
|