mirror of
https://github.com/c-cube/linol.git
synced 2026-01-22 17:36:40 -05:00
2 lines
8.7 KiB
HTML
2 lines
8.7 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>State (ocaml.Stdlib.Random.State)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 2.4.2"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> – <a href="../../../index.html">ocaml</a> » <a href="../../index.html">Stdlib</a> » <a href="../index.html">Random</a> » State</nav><header class="odoc-preamble"><h1>Module <code><span>Random.State</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-t"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span></code></div><div class="spec-doc"><p>The type of PRNG states.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-make"><a href="#val-make" class="anchor"></a><code><span><span class="keyword">val</span> make : <span><span>int array</span> <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Create a new state and initialize it with the given seed.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-make_self_init"><a href="#val-make_self_init" class="anchor"></a><code><span><span class="keyword">val</span> make_self_init : <span>unit <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Create a new state and initialize it with a random seed chosen in a system-dependent way. The seed is obtained as described in <a href="../index.html#val-self_init"><code>Random.self_init</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-copy"><a href="#val-copy" class="anchor"></a><code><span><span class="keyword">val</span> copy : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Return a copy of the given state.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-bits"><a href="#val-bits" class="anchor"></a><code><span><span class="keyword">val</span> bits : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> int</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-int"><a href="#val-int" class="anchor"></a><code><span><span class="keyword">val</span> int : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> int</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-full_int"><a href="#val-full_int" class="anchor"></a><code><span><span class="keyword">val</span> full_int : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> int</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-int32"><a href="#val-int32" class="anchor"></a><code><span><span class="keyword">val</span> int32 : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><a href="../../Int32/index.html#type-t">Int32.t</a> <span class="arrow">-></span></span> <a href="../../Int32/index.html#type-t">Int32.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-nativeint"><a href="#val-nativeint" class="anchor"></a><code><span><span class="keyword">val</span> nativeint : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><a href="../../Nativeint/index.html#type-t">Nativeint.t</a> <span class="arrow">-></span></span> <a href="../../Nativeint/index.html#type-t">Nativeint.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-int64"><a href="#val-int64" class="anchor"></a><code><span><span class="keyword">val</span> int64 : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><a href="../../Int64/index.html#type-t">Int64.t</a> <span class="arrow">-></span></span> <a href="../../Int64/index.html#type-t">Int64.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-float"><a href="#val-float" class="anchor"></a><code><span><span class="keyword">val</span> float : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span>float <span class="arrow">-></span></span> float</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-bool"><a href="#val-bool" class="anchor"></a><code><span><span class="keyword">val</span> bool : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> bool</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-bits32"><a href="#val-bits32" class="anchor"></a><code><span><span class="keyword">val</span> bits32 : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="../../Int32/index.html#type-t">Int32.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-bits64"><a href="#val-bits64" class="anchor"></a><code><span><span class="keyword">val</span> bits64 : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="../../Int64/index.html#type-t">Int64.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-nativebits"><a href="#val-nativebits" class="anchor"></a><code><span><span class="keyword">val</span> nativebits : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="../../Nativeint/index.html#type-t">Nativeint.t</a></span></code></div><div class="spec-doc"><p>These functions are the same as the basic functions, except that they use (and update) the given PRNG state instead of the default one.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-split"><a href="#val-split" class="anchor"></a><code><span><span class="keyword">val</span> split : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Draw a fresh PRNG state from the given PRNG state. (The given PRNG state is modified.) The new PRNG is statistically independent from the given PRNG. Data can be drawn from both PRNGs, in any order, without risk of correlation. Both PRNGs can be split later, arbitrarily many times.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 5.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-to_binary_string"><a href="#val-to_binary_string" class="anchor"></a><code><span><span class="keyword">val</span> to_binary_string : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> string</span></code></div><div class="spec-doc"><p>Serializes the PRNG state into an immutable sequence of bytes. See <a href="#val-of_binary_string"><code>of_binary_string</code></a> for deserialization.</p><p>The <code>string</code> type is intended here for serialization only, the encoding is not human-readable and may not be printable.</p><p>Note that the serialization format may differ across OCaml versions.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 5.1</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-of_binary_string"><a href="#val-of_binary_string" class="anchor"></a><code><span><span class="keyword">val</span> of_binary_string : <span>string <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Deserializes a byte sequence obtained by calling <a href="#val-to_binary_string"><code>to_binary_string</code></a>. The resulting PRNG state will produce the same random numbers as the state that was passed as input to <a href="#val-to_binary_string"><code>to_binary_string</code></a>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <a href="../../index.html#exception-Failure"><code>Failure</code></a> <p>if the input is not in the expected format.</p><p>Note that the serialization format may differ across OCaml versions.</p><p>Unlike the functions provided by the <a href="../../Marshal/index.html"><code>Marshal</code></a> module, this function either produces a valid state or fails cleanly with a <code>Failure</code> exception. It can be safely used on user-provided, untrusted inputs.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 5.1</li></ul></div></div></div></body></html>
|