728x90
반응형
- 2015-11-23 : 천천히 정리중.
random(0,10)%7
를 이용해서 [0, 7) random number 를 만들려고 하면, {0, 1, 2} set 가 {3, 4, 5, 6} set 보다 나올 확률이 두배 더 높아지기 때문이다. 뭐 아주 큰 수의 random generator 에서 작은 수로 mod 할때는 오차가 크지는 않겠지만... 그래도 (과학적인 연구용 프로그램이라던지 해서) 아주 엄밀하게 하고 싶다면 이런것까지 주의해야 한다.
그래서 보통 int b = (int)(Math.random()*10);
요런식으로 범위를 줄이는듯?
## JAVA
```
import java.util.Math;
double a = Math.random(); // [0, 1.0) : 0 (inclusive) to 1.0 (exclusive) random double number
int b = (int)(Math.random()*10); // [0, 10)
```/
```
import java.util.Random;
Random random = new Random();
int a = random.nextInt(bound); // [0, bound) : 0 (inclusive) to bound (exclusive) random integer number
```/
## WELL
Abstract: (출처 : )
Fast uniform random number generators with extremely long periods have been defined and implemented based on linear recurrences modulo 2. The twisted GFSR and the Mersenne twister are famous recent examples. Besides the period length, the statistical quality of these generators is usually assessed via their equidistribution properties. The huge-period generators proposed so far are not quite optimal in that respect. In this paper, we propose new generators, with better equidistribution and “bit-mixing” properties for equivalent period length and speed. Approximately half of the coefficients of the characteristic polynomial of these generators are nonzero. The state of our new generators evolves in a more chaotic way than for the Mersenne twister. We illustrate how this can reduce the impact of persistent dependencies among successive output values, which can be observed in certain parts of the period of gigantic generators such as the Mersenne twister.
Keywords: Random number generation, linear feedback shift register, GFSR linear recurrence modulo 2, Mersenne twister.
## RRA
728x90
반응형