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
19 <function>g_random_*</function> functions, which will create a globally
20 used #GRand and use the according <function>g_rand_*</function> functions
21 internally. Whenever you need a stream of reproducible random numbers, you
22 better create a #GRand yourself and use the <funcion>g_rand_*</function>
23 functions directly, which will also be slightly faster. Initializing a #GRand
24 with a certain seed will produce exactly the same series of random numbers
25 on all platforms. This can thus be used as a seed for e.g. games.
29 The <function>g_rand*_range</function> functions will return high quality
30 equally 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 <function>g_rand_*</function> 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 Returns 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 ##### -->
99 <!-- ##### FUNCTION g_rand_double ##### -->
106 <!-- ##### FUNCTION g_rand_double_range ##### -->
115 <!-- ##### FUNCTION g_random_set_seed ##### -->
121 <!-- ##### MACRO g_random_boolean ##### -->
123 Returns a random #gboolean. This corresponds to a unbiased coin toss.
126 @Returns: a random #gboolean.
129 <!-- ##### FUNCTION g_random_int ##### -->
135 <!-- ##### FUNCTION g_random_int_range ##### -->
143 <!-- ##### FUNCTION g_random_double ##### -->
149 <!-- ##### FUNCTION g_random_double_range ##### -->