Google

Go to the first, previous, next, last section, table of contents.


random

random([seed])
:: 乱数を生成する.
seed
return
自然数
  • 最大 2^32-1 の非負整数の乱数を生成する.
  • 0 でない引数がある時, その値を seed として設定してから, 乱数を生成する.
  • default の seed は固定のため, 種を設定しなければ, 生成される乱数の 系列は起動毎に一定である.
  • 松本眞-西村拓士による Mersenne Twister (http://www.math.keio.ac.jp/matsumoto/mt.html) アルゴリズムの, 彼ら自身による実装を用いている.
  • 周期は 2^19937-1 と非常に長い.
  • mt_save により state をファイルに save できる. これを mt_load で読み込むことにより, 異る Asir セッション間で一つの乱数の系列を辿ることが できる.
参照
section lrandom, section mt_save, mt_load.


Go to the first, previous, next, last section, table of contents.