Previous: Trigonometric Functions, Up: Mathematical Functions [Contents][Index]
ランダムステートオブジェクトは、乱数生成器の状態を表します。 状態は、627個の32ビットワードで構成されます。
make_random_state (n)
は、
nを2^32で割った余りに等しい整数シードの値から新しいランダムステートオブジェクトを
生成します。nは負でもいいです。
make_random_state (s)
は、ランダムステートsのコピーを返します。
make_random_state (true)
は、新しいランダムステートオブジェクトを返します。
シードとしてコンピュータの現在時刻を使います。
make_random_state (false)
は、乱数生成器の現在のステートのコピーを返します。
sを乱数生成器状態にコピーします。
set_random_state
はいつもdone
を返します。
疑似乱数を返します。
もしxが整数なら、random (x)
は、0からx - 1
までの
整数を返します。
もしxが浮動小数点なら、random (x)
は、xより小さい非負の浮動小数点を返します。
もしxが整数でも浮動小数点でもなかったり、xが正でなければ、
random
は、エラーを出力します。
関数make_random_state
とset_random_state
は、
乱数生成器の状態を保守します。
Maximaの乱数生成器は、メルセンヌ・ツイスタ MT 19937の実装です。
例:
(%i1) s1: make_random_state (654321)$ (%i2) set_random_state (s1); (%o2) done (%i3) random (1000); (%o3) 768 (%i4) random (9573684); (%o4) 7657880 (%i5) random (2^75); (%o5) 11804491615036831636390 (%i6) s2: make_random_state (false)$ (%i7) random (1.0); (%o7) .2310127244107132 (%i8) random (10.0); (%o8) 4.394553645870825 (%i9) random (100.0); (%o9) 32.28666704056853 (%i10) set_random_state (s2); (%o10) done (%i11) random (1.0); (%o11) .2310127244107132 (%i12) random (10.0); (%o12) 4.394553645870825 (%i13) random (100.0); (%o13) 32.28666704056853
Previous: Trigonometric Functions, Up: Mathematical Functions [Contents][Index]