Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > 156b156a753eb1eca909d87d09f203ae > files > 20

ghc-mwc-random-devel-0.12.0.1-2.fc18.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>System.Random.MWC.CondensedTable</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_System-Random-MWC-CondensedTable.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/System-Random-MWC-CondensedTable.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">mwc-random-0.12.0.1: Fast, high quality pseudo random number generation</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>portable</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Maintainer</th><td>bos@serpentine.com</td></tr><tr><th>Safe Haskell</th><td>Safe-Infered</td></tr></table><p class="caption">System.Random.MWC.CondensedTable</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Condensed tables
</a></li><li><a href="#g:2">Constructors for tables
</a><ul><li><a href="#g:3">Disrete distributions
</a></li></ul></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Table-driven generation of random variates.  This approach can
 generate random variates in <em>O(1)</em> time for the supported
 distributions, at a modest cost in initialization time.
</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span>  <a href="#t:CondensedTable">CondensedTable</a> v a</li><li class="src short"><span class="keyword">type</span> <a href="#t:CondensedTableV">CondensedTableV</a> = <a href="System-Random-MWC-CondensedTable.html#t:CondensedTable">CondensedTable</a> <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector.html#t:Vector">Vector</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:CondensedTableU">CondensedTableU</a> = <a href="System-Random-MWC-CondensedTable.html#t:CondensedTable">CondensedTable</a> <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Unboxed.html#t:Vector">Vector</a></li><li class="src short"><a href="#v:genFromTable">genFromTable</a> :: (<a href="/usr/share/doc/ghc/html/libraries/primitive-0.4.1/Control-Monad-Primitive.html#t:PrimMonad">PrimMonad</a> m, <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v a) =&gt; <a href="System-Random-MWC-CondensedTable.html#t:CondensedTable">CondensedTable</a> v a -&gt; <a href="System-Random-MWC.html#t:Gen">Gen</a> (<a href="/usr/share/doc/ghc/html/libraries/primitive-0.4.1/Control-Monad-Primitive.html#t:PrimState">PrimState</a> m) -&gt; m a</li><li class="src short"><a href="#v:tableFromProbabilities">tableFromProbabilities</a> :: (<a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word32">Word32</a>), <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#t:Double">Double</a>), <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v a, <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word32">Word32</a>, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Text-Show.html#t:Show">Show</a> a) =&gt; v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#t:Double">Double</a>) -&gt; <a href="System-Random-MWC-CondensedTable.html#t:CondensedTable">CondensedTable</a> v a</li><li class="src short"><a href="#v:tableFromWeights">tableFromWeights</a> :: (<a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word32">Word32</a>), <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#t:Double">Double</a>), <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v a, <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word32">Word32</a>, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Text-Show.html#t:Show">Show</a> a) =&gt; v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#t:Double">Double</a>) -&gt; <a href="System-Random-MWC-CondensedTable.html#t:CondensedTable">CondensedTable</a> v a</li><li class="src short"><a href="#v:tableFromIntWeights">tableFromIntWeights</a> :: (<a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word32">Word32</a>), <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v a, <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word32">Word32</a>) =&gt; v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word32">Word32</a>) -&gt; <a href="System-Random-MWC-CondensedTable.html#t:CondensedTable">CondensedTable</a> v a</li><li class="src short"><a href="#v:tablePoisson">tablePoisson</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#t:Double">Double</a> -&gt; <a href="System-Random-MWC-CondensedTable.html#t:CondensedTableU">CondensedTableU</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:tableBinomial">tableBinomial</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#t:Double">Double</a> -&gt; <a href="System-Random-MWC-CondensedTable.html#t:CondensedTableU">CondensedTableU</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a></li></ul></div><div id="interface"><h1 id="g:1">Condensed tables
</h1><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:CondensedTable" class="def">CondensedTable</a> v a <a href="src/System-Random-MWC-CondensedTable.html#CondensedTable" class="link">Source</a></p><div class="doc"><p>A lookup table for arbitrary discrete distributions. It allows
 the generation of random variates in <em>O(1)</em>. Note that probability
 is quantized in units of <code>1/2^32</code>, and all distributions with
 infinite support (e.g. Poisson) should be truncated.
</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:CondensedTableV" class="def">CondensedTableV</a> = <a href="System-Random-MWC-CondensedTable.html#t:CondensedTable">CondensedTable</a> <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector.html#t:Vector">Vector</a><a href="src/System-Random-MWC-CondensedTable.html#CondensedTableV" class="link">Source</a></p><div class="doc"><p>A <code><a href="System-Random-MWC-CondensedTable.html#t:CondensedTable">CondensedTable</a></code> that uses boxed vectors, and is able to hold
 any type of element.
</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:CondensedTableU" class="def">CondensedTableU</a> = <a href="System-Random-MWC-CondensedTable.html#t:CondensedTable">CondensedTable</a> <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Unboxed.html#t:Vector">Vector</a><a href="src/System-Random-MWC-CondensedTable.html#CondensedTableU" class="link">Source</a></p><div class="doc"><p>A <code><a href="System-Random-MWC-CondensedTable.html#t:CondensedTable">CondensedTable</a></code> that uses unboxed vectors.
</p></div></div><div class="top"><p class="src"><a name="v:genFromTable" class="def">genFromTable</a> :: (<a href="/usr/share/doc/ghc/html/libraries/primitive-0.4.1/Control-Monad-Primitive.html#t:PrimMonad">PrimMonad</a> m, <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v a) =&gt; <a href="System-Random-MWC-CondensedTable.html#t:CondensedTable">CondensedTable</a> v a -&gt; <a href="System-Random-MWC.html#t:Gen">Gen</a> (<a href="/usr/share/doc/ghc/html/libraries/primitive-0.4.1/Control-Monad-Primitive.html#t:PrimState">PrimState</a> m) -&gt; m a<a href="src/System-Random-MWC-CondensedTable.html#genFromTable" class="link">Source</a></p><div class="doc"><p>Generate a random value using a condensed table.
</p></div></div><h1 id="g:2">Constructors for tables
</h1><div class="top"><p class="src"><a name="v:tableFromProbabilities" class="def">tableFromProbabilities</a> :: (<a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word32">Word32</a>), <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#t:Double">Double</a>), <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v a, <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word32">Word32</a>, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Text-Show.html#t:Show">Show</a> a) =&gt; v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#t:Double">Double</a>) -&gt; <a href="System-Random-MWC-CondensedTable.html#t:CondensedTable">CondensedTable</a> v a<a href="src/System-Random-MWC-CondensedTable.html#tableFromProbabilities" class="link">Source</a></p><div class="doc"><p>Generate a condensed lookup table from a list of outcomes with
 given probabilities. The vector should be non-empty and the
 probabilites should be non-negative and sum to 1. If this is not
 the case, this algorithm will construct a table for some
 distribution that may bear no resemblance to what you intended.
</p></div></div><div class="top"><p class="src"><a name="v:tableFromWeights" class="def">tableFromWeights</a> :: (<a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word32">Word32</a>), <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#t:Double">Double</a>), <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v a, <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word32">Word32</a>, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Text-Show.html#t:Show">Show</a> a) =&gt; v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#t:Double">Double</a>) -&gt; <a href="System-Random-MWC-CondensedTable.html#t:CondensedTable">CondensedTable</a> v a<a href="src/System-Random-MWC-CondensedTable.html#tableFromWeights" class="link">Source</a></p><div class="doc"><p>Same as <code><a href="System-Random-MWC-CondensedTable.html#v:tableFromProbabilities">tableFromProbabilities</a></code> but treats number as weights not
 probilities. Non-positive weights are discarded, and those
 remaining are normalized to 1.
</p></div></div><div class="top"><p class="src"><a name="v:tableFromIntWeights" class="def">tableFromIntWeights</a> :: (<a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word32">Word32</a>), <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v a, <a href="/usr/share/doc/ghc/html/libraries/vector-0.9.1/Data-Vector-Generic.html#t:Vector">Vector</a> v <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word32">Word32</a>) =&gt; v (a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word32">Word32</a>) -&gt; <a href="System-Random-MWC-CondensedTable.html#t:CondensedTable">CondensedTable</a> v a<a href="src/System-Random-MWC-CondensedTable.html#tableFromIntWeights" class="link">Source</a></p><div class="doc"><p>Generate a condensed lookup table from integer weights. Weights
 should sum to <code>2^32</code>. If they don't, the algorithm will alter the
 weights so that they do. This approach should work reasonably well
 for rounding errors.
</p></div></div><h2 id="g:3">Disrete distributions
</h2><div class="top"><p class="src"><a name="v:tablePoisson" class="def">tablePoisson</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#t:Double">Double</a> -&gt; <a href="System-Random-MWC-CondensedTable.html#t:CondensedTableU">CondensedTableU</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a><a href="src/System-Random-MWC-CondensedTable.html#tablePoisson" class="link">Source</a></p><div class="doc"><p>Create a lookup table for the Poisson distibution. Note that
 table construction may have significant cost. For &#955; &lt; 100 it
 takes as much time to build table as generation of 1000-30000
 variates.
</p></div></div><div class="top"><p class="src"><a name="v:tableBinomial" class="def">tableBinomial</a><a href="src/System-Random-MWC-CondensedTable.html#tableBinomial" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a></td><td class="doc"><p>Number of tries
</p></td></tr><tr><td class="src">-&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#t:Double">Double</a></td><td class="doc"><p>Probability of success
</p></td></tr><tr><td class="src">-&gt; <a href="System-Random-MWC-CondensedTable.html#t:CondensedTableU">CondensedTableU</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a></td><td class="doc empty">&nbsp;</td></tr></table></div><div class="doc"><p>Create a lookup table for the binomial distribution.
</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.10.0</p></div></body></html>