1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 pseudo random number generator.
7 <!-- ##### SECTION Long_Description ##### -->
9 The following functions allow you to use a portable, fast and good
10 pseudo random number generator (PRNG). It uses the Mersenne Twister
11 PRNG, which was originally developed by Makoto Matsumoto and Takuji
12 Nishimura. Further information can be found at <ulink
13 url="http://www.math.keio.ac.jp/~matumoto/emt.html"
14 >www.math.keio.ac.jp/~matumoto/emt.html</ulink>.
18 If you just need a random number, you simply call the g_random_*
19 functions, which will create a globally used #GRand and use the
20 according g_rand_* function internally. Whenever you need a stream of
21 reproducible random numbers, you better create a #GRand yourself and
22 use the g_rand_* functions directly, which will also be slightly
23 faster. Initializing a GRand with a certain seed will produce exactly
24 the same series of random numbers on all platforms. This can thus be
25 used as a seed for e.g. games.
29 The g_rand*_range functions will return high quality equally
30 distributed random numbers, whereas for example the
31 <literal>(g_random_int()%%max)</literal> approach often doesn't
32 yield equally distributed numbers.
35 <!-- ##### SECTION See_Also ##### -->
40 <!-- ##### STRUCT GRand ##### -->
42 The #GRand struct is an opaque data structure. It should only be
43 accessed through the g_rand_* functions.
47 <!-- ##### FUNCTION g_rand_new_with_seed ##### -->
54 <!-- ##### FUNCTION g_rand_new ##### -->
60 <!-- ##### FUNCTION g_rand_free ##### -->
66 <!-- ##### FUNCTION g_rand_set_seed ##### -->
73 <!-- ##### MACRO g_rand_boolean ##### -->
75 Return a random #gboolean from @rand. This corresponds to a unbiased
80 @Returns: a random #gboolean.
83 <!-- ##### FUNCTION g_rand_int ##### -->
90 <!-- ##### FUNCTION g_rand_int_range ##### -->
97 <!-- # Unused Parameters # -->
102 <!-- ##### FUNCTION g_rand_double ##### -->
109 <!-- ##### FUNCTION g_rand_double_range ##### -->
116 <!-- # Unused Parameters # -->
121 <!-- ##### FUNCTION g_random_set_seed ##### -->
127 <!-- ##### MACRO g_random_boolean ##### -->
129 Return a random #gboolean. This corresponds to a unbiased coin toss.
132 @Returns: a random #gboolean.
135 <!-- ##### FUNCTION g_random_int ##### -->
141 <!-- ##### FUNCTION g_random_int_range ##### -->
147 <!-- # Unused Parameters # -->
152 <!-- ##### FUNCTION g_random_double ##### -->
158 <!-- ##### FUNCTION g_random_double_range ##### -->
164 <!-- # Unused Parameters # -->