Commit 02f80f88 authored by Valentin Reis's avatar Valentin Reis
Browse files

Merge branch 'develop' into 'master'

Adds Exp4R

See merge request !1
parents 173bb572 9ebd2593
Pipeline #9886 failed with stages
in 12 seconds
# hbandit
Multi-Armed Bandit implementations: UCB & EXP family of algorithms, BwCR.
Multi-Armed Bandit implementations: EXP, BwCR (wip), Exp4.R
## Install
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!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>HBandit.Types</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><link rel="stylesheet" type="text/css" href="quick-jump.css" /><script src="haddock-bundle.min.js" async="async" type="text/javascript"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hbandit</p></div><div id="content"><div id="module-header"><table class="info"><tr><th valign="top">Copyright</th><td>(c) 2019 UChicago Argonne LLC.</td></tr><tr><th>License</th><td>MIT</td></tr><tr><th>Maintainer</th><td>fre@freux.fr</td></tr><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">HBandit.Types</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Utility functions for MAB algorithms.</p></div></div><div id="synopsis"><details id="syn"><summary>Synopsis</summary><ul class="details-toggle" data-details-id="syn"><li class="src short"><span class="keyword">type</span> <a href="#t:ZeroOne">ZeroOne</a> l = <a href="&quot;https://hackage.haskell.org/package/\refined-\0.4.2.1/docs&quot;/Refined-Internal.html#t:Refined" title="Refined.Internal">Refined</a> (<a href="&quot;https://hackage.haskell.org/package/\refined-\0.4.2.1/docs&quot;/Refined-Internal.html#t:FromTo" title="Refined.Internal">FromTo</a> 0 1) l</li><li class="src short"><a href="#v:zero">zero</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Num" title="Prelude">Num</a> a) =&gt; <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a</li><li class="src short"><a href="#v:one">one</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Num" title="Prelude">Num</a> a) =&gt; <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a</li><li class="src short"><a href="#v:normalize">normalize</a> :: <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Double" title="Prelude">Double</a> -&gt; <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Double" title="Prelude">Double</a> -&gt; <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/GHC-Maybe.html#t:Maybe" title="GHC.Maybe">Maybe</a> (<a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Double" title="Prelude">Double</a>)</li><li class="src short"><a href="#v:normalizedSum">normalizedSum</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Fractional" title="Prelude">Fractional</a> a) =&gt; [(<a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a, <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a)] -&gt; <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a</li></ul></details></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:ZeroOne" class="def">ZeroOne</a> l = <a href="&quot;https://hackage.haskell.org/package/\refined-\0.4.2.1/docs&quot;/Refined-Internal.html#t:Refined" title="Refined.Internal">Refined</a> (<a href="&quot;https://hackage.haskell.org/package/\refined-\0.4.2.1/docs&quot;/Refined-Internal.html#t:FromTo" title="Refined.Internal">FromTo</a> 0 1) l <a href="#t:ZeroOne" class="selflink">#</a></p><div class="doc"><p>Type alias for a \(\mathbb{L}=[0,1]\) refined value.</p></div></div><div class="top"><p class="src"><a id="v:zero" class="def">zero</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Num" title="Prelude">Num</a> a) =&gt; <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a <a href="#v:zero" class="selflink">#</a></p><div class="doc"><p>0</p></div></div><div class="top"><p class="src"><a id="v:one" class="def">one</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Num" title="Prelude">Num</a> a) =&gt; <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a <a href="#v:one" class="selflink">#</a></p><div class="doc"><p>1</p></div></div><div class="top"><p class="src"><a id="v:normalize" class="def">normalize</a> :: <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Double" title="Prelude">Double</a> -&gt; <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Double" title="Prelude">Double</a> -&gt; <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/GHC-Maybe.html#t:Maybe" title="GHC.Maybe">Maybe</a> (<a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Double" title="Prelude">Double</a>) <a href="#v:normalize" class="selflink">#</a></p><div class="doc"><p><code>normalize x xm</code> normalizes <code>x</code> using <code>xm</code>. Returns <code>Nothing</code>
in case the resulting value is not contained in $[0,1]$ .</p></div></div><div class="top"><p class="src"><a id="v:normalizedSum" class="def">normalizedSum</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Fractional" title="Prelude">Fractional</a> a) =&gt; [(<a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a, <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a)] -&gt; <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a <a href="#v:normalizedSum" class="selflink">#</a></p><div class="doc"><p><code>normalizedSum</code> sums the <code><a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Tuple.html#v:snd" title="Data.Tuple">snd</a></code> from the tuple list using weights
in the <code><a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Tuple.html#v:fst" title="Data.Tuple">fst</a></code>. The result is normalized against the list of <code><a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Tuple.html#v:fst" title="Data.Tuple">fst</a></code>s.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.22.0</p></div></body></html>
\ No newline at end of file
<!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>HBandit.Types</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><link rel="stylesheet" type="text/css" href="quick-jump.css" /><script src="haddock-bundle.min.js" async="async" type="text/javascript"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hbandit</p></div><div id="content"><div id="module-header"><table class="info"><tr><th valign="top">Copyright</th><td>(c) 2019 UChicago Argonne LLC.</td></tr><tr><th>License</th><td>MIT</td></tr><tr><th>Maintainer</th><td>fre@freux.fr</td></tr><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">HBandit.Types</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Utility functions for MAB algorithms.</p></div></div><div id="synopsis"><details id="syn"><summary>Synopsis</summary><ul class="details-toggle" data-details-id="syn"><li class="src short"><span class="keyword">type</span> <a href="#t:ZeroOne">ZeroOne</a> l = <a href="&quot;https://hackage.haskell.org/package/\refined-\0.4.2.1/docs&quot;/Refined-Internal.html#t:Refined" title="Refined.Internal">Refined</a> (<a href="&quot;https://hackage.haskell.org/package/\refined-\0.4.2.1/docs&quot;/Refined-Internal.html#t:FromTo" title="Refined.Internal">FromTo</a> 0 1) l</li><li class="src short"><a href="#v:zero">zero</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Num" title="Prelude">Num</a> a) =&gt; <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a</li><li class="src short"><a href="#v:one">one</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Num" title="Prelude">Num</a> a) =&gt; <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a</li></ul></details></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:ZeroOne" class="def">ZeroOne</a> l = <a href="&quot;https://hackage.haskell.org/package/\refined-\0.4.2.1/docs&quot;/Refined-Internal.html#t:Refined" title="Refined.Internal">Refined</a> (<a href="&quot;https://hackage.haskell.org/package/\refined-\0.4.2.1/docs&quot;/Refined-Internal.html#t:FromTo" title="Refined.Internal">FromTo</a> 0 1) l <a href="#t:ZeroOne" class="selflink">#</a></p><div class="doc"><p>Type alias for a \(\mathbb{L}=[0,1]\) refined value.</p></div></div><div class="top"><p class="src"><a id="v:zero" class="def">zero</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Num" title="Prelude">Num</a> a) =&gt; <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a <a href="#v:zero" class="selflink">#</a></p><div class="doc"><p>0</p></div></div><div class="top"><p class="src"><a id="v:one" class="def">one</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Num" title="Prelude">Num</a> a) =&gt; <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a <a href="#v:one" class="selflink">#</a></p><div class="doc"><p>1</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.22.0</p></div></body></html>
\ No newline at end of file
<!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>HBandit.Util</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><link rel="stylesheet" type="text/css" href="quick-jump.css" /><script src="haddock-bundle.min.js" async="async" type="text/javascript"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hbandit</p></div><div id="content"><div id="module-header"><table class="info"><tr><th valign="top">Copyright</th><td>(c) 2019 UChicago Argonne LLC.</td></tr><tr><th>License</th><td>MIT</td></tr><tr><th>Maintainer</th><td>fre@freux.fr</td></tr><tr><th>Safe Haskell</th><td>Safe</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">HBandit.Util</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Utility functions for MAB algorithms.</p></div></div><div id="synopsis"><details id="syn"><summary>Synopsis</summary><ul class="details-toggle" data-details-id="syn"><li class="src short"><a href="#v:sampleWL">sampleWL</a> :: <a href="&quot;https://hackage.haskell.org/package/\random-\1.1/docs&quot;/System-Random.html#t:RandomGen" title="System.Random">RandomGen</a> g =&gt; [(<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Double" title="Prelude">Double</a>, a)] -&gt; g -&gt; (a, g)</li></ul></details></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a id="v:sampleWL" class="def">sampleWL</a> :: <a href="&quot;https://hackage.haskell.org/package/\random-\1.1/docs&quot;/System-Random.html#t:RandomGen" title="System.Random">RandomGen</a> g =&gt; [(<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Double" title="Prelude">Double</a>, a)] -&gt; g -&gt; (a, g) <a href="#v:sampleWL" class="selflink">#</a></p><div class="doc"><p>Samples from a weighted probability distribution.
The sum of weights must not be zero.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.22.0</p></div></body></html>
\ No newline at end of file
<!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>HBandit.Util</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><link rel="stylesheet" type="text/css" href="quick-jump.css" /><script src="haddock-bundle.min.js" async="async" type="text/javascript"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hbandit</p></div><div id="content"><div id="module-header"><table class="info"><tr><th valign="top">Copyright</th><td>(c) 2019 UChicago Argonne LLC.</td></tr><tr><th>License</th><td>MIT</td></tr><tr><th>Maintainer</th><td>fre@freux.fr</td></tr><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">HBandit.Util</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Utility functions for MAB algorithms.</p></div></div><div id="synopsis"><details id="syn"><summary>Synopsis</summary><ul class="details-toggle" data-details-id="syn"><li class="src short"><a href="#v:sampleWL">sampleWL</a> :: <a href="&quot;https://hackage.haskell.org/package/\random-\1.1/docs&quot;/System-Random.html#t:RandomGen" title="System.Random">RandomGen</a> g =&gt; <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-List-NonEmpty.html#t:NonEmpty" title="Data.List.NonEmpty">NonEmpty</a> (<a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Double" title="Prelude">Double</a>, a) -&gt; g -&gt; (a, g)</li><li class="src short"><a href="#v:normalize">normalize</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Numeric.html#t:Floating" title="Numeric">Floating</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a) =&gt; a -&gt; a -&gt; <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/GHC-Maybe.html#t:Maybe" title="GHC.Maybe">Maybe</a> (<a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a)</li><li class="src short"><a href="#v:unsafeNormalizePanic">unsafeNormalizePanic</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Numeric.html#t:Floating" title="Numeric">Floating</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a) =&gt; a -&gt; a -&gt; <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a</li><li class="src short"><a href="#v:normalizeDistribution">normalizeDistribution</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Numeric.html#t:Floating" title="Numeric">Floating</a> p, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> p) =&gt; <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-List-NonEmpty.html#t:NonEmpty" title="Data.List.NonEmpty">NonEmpty</a> (p, a) -&gt; <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/GHC-Maybe.html#t:Maybe" title="GHC.Maybe">Maybe</a> (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-List-NonEmpty.html#t:NonEmpty" title="Data.List.NonEmpty">NonEmpty</a> (<a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> p, a))</li><li class="src short"><a href="#v:normalizedSum">normalizedSum</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Fractional" title="Prelude">Fractional</a> a) =&gt; [(<a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a, <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a)] -&gt; <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a</li></ul></details></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a id="v:sampleWL" class="def">sampleWL</a> :: <a href="&quot;https://hackage.haskell.org/package/\random-\1.1/docs&quot;/System-Random.html#t:RandomGen" title="System.Random">RandomGen</a> g =&gt; <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-List-NonEmpty.html#t:NonEmpty" title="Data.List.NonEmpty">NonEmpty</a> (<a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Double" title="Prelude">Double</a>, a) -&gt; g -&gt; (a, g) <a href="#v:sampleWL" class="selflink">#</a></p><div class="doc"><p>Samples from a weighted probability distribution.
The sum of weights must not be zero.</p></div></div><div class="top"><p class="src"><a id="v:normalize" class="def">normalize</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Numeric.html#t:Floating" title="Numeric">Floating</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a) =&gt; a -&gt; a -&gt; <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/GHC-Maybe.html#t:Maybe" title="GHC.Maybe">Maybe</a> (<a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a) <a href="#v:normalize" class="selflink">#</a></p><div class="doc"><p><code>normalize x xm</code> normalizes <code>x</code> using <code>xm</code>. Returns <code>Nothing</code>
in case the resulting value is not contained in $[0,1]$ .</p></div></div><div class="top"><p class="src"><a id="v:unsafeNormalizePanic" class="def">unsafeNormalizePanic</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Numeric.html#t:Floating" title="Numeric">Floating</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a) =&gt; a -&gt; a -&gt; <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a <a href="#v:unsafeNormalizePanic" class="selflink">#</a></p><div class="doc"><p><code>normalize x xm</code> normalizes <code>x</code> using <code>xm</code>. Returns <code>Nothing</code>
in case the resulting value is not contained in $[0,1]$ .</p></div></div><div class="top"><p class="src"><a id="v:normalizeDistribution" class="def">normalizeDistribution</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Numeric.html#t:Floating" title="Numeric">Floating</a> p, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> p) =&gt; <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-List-NonEmpty.html#t:NonEmpty" title="Data.List.NonEmpty">NonEmpty</a> (p, a) -&gt; <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/GHC-Maybe.html#t:Maybe" title="GHC.Maybe">Maybe</a> (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-List-NonEmpty.html#t:NonEmpty" title="Data.List.NonEmpty">NonEmpty</a> (<a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> p, a)) <a href="#v:normalizeDistribution" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:normalizedSum" class="def">normalizedSum</a> :: (<a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Ord.html#t:Ord" title="Data.Ord">Ord</a> a, <a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Prelude.html#t:Fractional" title="Prelude">Fractional</a> a) =&gt; [(<a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a, <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a)] -&gt; <a href="HBandit-Types.html#t:ZeroOne" title="HBandit.Types">ZeroOne</a> a <a href="#v:normalizedSum" class="selflink">#</a></p><div class="doc"><p><code>normalizedSum</code> sums the <code><a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Tuple.html#v:snd" title="Data.Tuple">snd</a></code> from the tuple list using weights
in the <code><a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Tuple.html#v:fst" title="Data.Tuple">fst</a></code>. The result is normalized against the list of <code><a href="&quot;https://hackage.haskell.org/package/\base-\4.12.0.0/docs&quot;/Data-Tuple.html#v:fst" title="Data.Tuple">fst</a></code>s.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.22.0</p></div></body></html>
\ No newline at end of file
This diff is collapsed.
<!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>hbandit</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><link rel="stylesheet" type="text/css" href="quick-jump.css" /><script src="haddock-bundle.min.js" async="async" type="text/javascript"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hbandit</p></div><div id="content"><div id="description"><h1>hbandit</h1><div class="doc"><p>hbandit</p></div></div><div id="module-list"><p class="caption">Signatures</p></div><div id="module-list"><p class="caption">Modules</p><ul><li><span class="module details-toggle-control details-toggle" data-details-id="n.1">FFI</span><details id="n.1" open="open"><summary class="hide-when-js-enabled">Submodules</summary><ul><li><span class="module"><span class="details-toggle-control details-toggle" data-details-id="n.1.1">&nbsp;</span><a href="FFI-TypeUncurry.html">FFI.TypeUncurry</a></span><details id="n.1.1" open="open"><summary class="hide-when-js-enabled">Submodules</summary><ul><li><span class="module"><a href="FFI-TypeUncurry-DataKinds.html">FFI.TypeUncurry.DataKinds</a></span></li><li><span class="module"><a href="FFI-TypeUncurry-Msgpack.html">FFI.TypeUncurry.Msgpack</a></span></li></ul></details></li></ul></details></li><li><span class="module details-toggle-control details-toggle" data-details-id="n.2">HBandit</span><details id="n.2" open="open"><summary class="hide-when-js-enabled">Submodules</summary><ul><li><span class="module"><a href="HBandit-BwCR.html">HBandit.BwCR</a></span></li><li><span class="module"><a href="HBandit-Class.html">HBandit.Class</a></span></li><li><span class="module"><a href="HBandit-EpsGreedy.html">HBandit.EpsGreedy</a></span></li><li><span class="module"><a href="HBandit-Exp3.html">HBandit.Exp3</a></span></li><li><span class="module"><a href="HBandit-Types.html">HBandit.Types</a></span></li><li><span class="module"><a href="HBandit-Util.html">HBandit.Util</a></span></li></ul></details></li><li><span class="module"><a href="Shared.html">Shared</a></span></li></ul></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.22.0</p></div></body></html>
\ No newline at end of file
<!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>hbandit</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><link rel="stylesheet" type="text/css" href="quick-jump.css" /><script src="haddock-bundle.min.js" async="async" type="text/javascript"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hbandit</p></div><div id="content"><div id="description"><h1>hbandit</h1><div class="doc"><p>hbandit</p></div></div><div id="module-list"><p class="caption">Signatures</p></div><div id="module-list"><p class="caption">Modules</p><ul><li><span class="module details-toggle-control details-toggle" data-details-id="n.1">FFI</span><details id="n.1" open="open"><summary class="hide-when-js-enabled">Submodules</summary><ul><li><span class="module"><span class="details-toggle-control details-toggle" data-details-id="n.1.1">&nbsp;</span><a href="FFI-TypeUncurry.html">FFI.TypeUncurry</a></span><details id="n.1.1" open="open"><summary class="hide-when-js-enabled">Submodules</summary><ul><li><span class="module"><a href="FFI-TypeUncurry-DataKinds.html">FFI.TypeUncurry.DataKinds</a></span></li><li><span class="module"><a href="FFI-TypeUncurry-Msgpack.html">FFI.TypeUncurry.Msgpack</a></span></li></ul></details></li></ul></details></li><li><span class="module details-toggle-control details-toggle" data-details-id="n.2">HBandit</span><details id="n.2" open="open"><summary class="hide-when-js-enabled">Submodules</summary><ul><li><span class="module"><a href="HBandit-BwCR.html">HBandit.BwCR</a></span></li><li><span class="module"><a href="HBandit-Class.html">HBandit.Class</a></span></li><li><span class="module"><a href="HBandit-EpsGreedy.html">HBandit.EpsGreedy</a></span></li><li><span class="module"><a href="HBandit-Exp3.html">HBandit.Exp3</a></span></li><li><span class="module"><a href="HBandit-Exp4R.html">HBandit.Exp4R</a></span></li><li><span class="module"><a href="HBandit-Types.html">HBandit.Types</a></span></li><li><span class="module"><a href="HBandit-Util.html">HBandit.Util</a></span></li></ul></details></li><li><span class="module"><a href="Shared.html">Shared</a></span></li></ul></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.22.0</p></div></body></html>
\ No newline at end of file
This diff is collapsed.
<!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><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE DataKinds #-}</span><span>
</span><a name="line-2"></a><span class="hs-pragma">{-# LANGUAGE FlexibleContexts #-}</span><span>
</span><a name="line-3"></a><span class="hs-pragma">{-# LANGUAGE ScopedTypeVariables #-}</span><span>
</span><a name="line-4"></a><span class="hs-pragma">{-# LANGUAGE TypeOperators #-}</span><span>
</span><a name="line-5"></a><span>
</span><a name="line-6"></a><span class="hs-comment">-- |</span><span>
</span><a name="line-7"></a><span class="hs-comment">-- Module : FFI.TypeUncurry</span><span>
</span><a name="line-8"></a><span class="hs-comment">-- Copyright : Copyright (c) 2018 Niklas Hamb&#252;chen.</span><span>
</span><a name="line-9"></a><span class="hs-comment">-- License : MIT License.</span><span>
</span><a name="line-10"></a><span class="hs-comment">--</span><span>
</span><a name="line-11"></a><span class="hs-comment">-- MessagePack FFI code adapted from call-haskell-from-anything</span><span>
</span><a name="line-12"></a><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">FFI.TypeUncurry</span><span>
</span><a name="line-13"></a><span> </span><span class="hs-special">(</span><span> </span><span class="hs-comment">-- | You see this because your compiler supports DataKinds.</span><span>
</span><a name="line-14"></a><span> </span><span class="hs-keyword">module</span><span> </span><a href="FFI.TypeUncurry.DataKinds.html"><span class="hs-identifier">FFI.TypeUncurry.DataKinds</span></a><span class="hs-special">,</span><span>
</span><a name="line-15"></a><span> </span><span class="hs-special">)</span><span>
</span><a name="line-16"></a><span class="hs-keyword">where</span><span>
</span><a name="line-17"></a><span>
</span><a name="line-18"></a><span class="hs-keyword">import</span><span> </span><a href="FFI.TypeUncurry.DataKinds.html"><span class="hs-identifier">FFI.TypeUncurry.DataKinds</span></a><span>
</span><a name="line-19"></a></pre></body></html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!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><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}</span><span>
</span><a name="line-2"></a><span class="hs-pragma">{-# OPTIONS_GHC -fno-warn-missing-local-signatures #-}</span><span>
</span><a name="line-3"></a><span>
</span><a name="line-4"></a><span class="hs-comment">-- |</span><span>
</span><a name="line-5"></a><span class="hs-comment">-- Module : HBandit.Util</span><span>
</span><a name="line-6"></a><span class="hs-comment">-- Copyright : (c) 2019, UChicago Argonne, LLC.</span><span>
</span><a name="line-7"></a><span class="hs-comment">-- License : MIT</span><span>
</span><a name="line-8"></a><span class="hs-comment">-- Maintainer : fre@freux.fr</span><span>
</span><a name="line-9"></a><span class="hs-comment">--</span><span>
</span><a name="line-10"></a><span class="hs-comment">-- Utility functions for MAB algorithms.</span><span>
</span><a name="line-11"></a><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">HBandit.Types</span><span>
</span><a name="line-12"></a><span> </span><span class="hs-special">(</span><span> </span><a href="HBandit.Types.html#ZeroOne"><span class="hs-identifier hs-type">ZeroOne</span></a><span class="hs-special">,</span><span>
</span><a name="line-13"></a><span> </span><a href="HBandit.Types.html#zero"><span class="hs-identifier hs-var">HBandit.Types.zero</span></a><span class="hs-special">,</span><span>
</span><a name="line-14"></a><span> </span><a href="HBandit.Types.html#one"><span class="hs-identifier hs-var">HBandit.Types.one</span></a><span class="hs-special">,</span><span>
</span><a name="line-15"></a><span> </span><a href="HBandit.Types.html#normalize"><span class="hs-identifier hs-var">normalize</span></a><span class="hs-special">,</span><span>
</span><a name="line-16"></a><span> </span><a href="HBandit.Types.html#normalizedSum"><span class="hs-identifier hs-var">normalizedSum</span></a><span class="hs-special">,</span><span>
</span><a name="line-17"></a><span> </span><span class="hs-special">)</span><span>
</span><a name="line-18"></a><span class="hs-keyword">where</span><span>
</span><a name="line-19"></a><span>
</span><a name="line-20"></a><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Protolude</span><span>
</span><a name="line-21"></a><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Refined</span><span>
</span><a name="line-22"></a><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Refined.Unsafe</span><span>
</span><a name="line-23"></a><span>
</span><a name="line-24"></a><span class="hs-comment">-- | Type alias for a \(\mathbb{L}=[0,1]\) refined value.</span><span>
</span><a name="line-25"></a><span class="hs-keyword">type</span><span> </span><a name="ZeroOne"><a href="HBandit.Types.html#ZeroOne"><span class="hs-identifier">ZeroOne</span></a></a><span> </span><a name="local-6989586621679090933"><a href="#local-6989586621679090933"><span class="hs-identifier">l</span></a></a><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-identifier hs-type">Refined</span><span> </span><span class="hs-special">(</span><span class="hs-identifier hs-type">FromTo</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-number">1</span><span class="hs-special">)</span><span> </span><a href="#local-6989586621679090933"><span class="hs-identifier hs-type">l</span></a><span class="hs-special">)</span><span>
</span><a name="line-26"></a><span>
</span><a name="line-27"></a><span class="hs-comment">-- | 0</span><span>
</span><a name="line-28"></a><span class="hs-identifier">zero</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-identifier hs-type">Ord</span><span> </span><a href="#local-6989586621679092150"><span class="hs-identifier hs-type">a</span></a><span class="hs-special">,</span><span> </span><span class="hs-identifier hs-type">Num</span><span> </span><a href="#local-6989586621679092150"><span class="hs-identifier hs-type">a</span></a><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><a href="HBandit.Types.html#ZeroOne"><span class="hs-identifier hs-type">ZeroOne</span></a><span> </span><a href="#local-6989586621679092150"><span class="hs-identifier hs-type">a</span></a><span>
</span><a name="line-29"></a><a name="zero"><a href="HBandit.Types.html#zero"><span class="hs-identifier">zero</span></a></a><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier hs-var">unsafeRefine</span><span> </span><span class="hs-number">0</span><span>
</span><a name="line-30"></a><span>
</span><a name="line-31"></a><span class="hs-comment">-- | 1</span><span>
</span><a name="line-32"></a><span class="hs-identifier">one</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-identifier hs-type">Ord</span><span> </span><a href="#local-6989586621679092149"><span class="hs-identifier hs-type">a</span></a><span class="hs-special">,</span><span> </span><span class="hs-identifier hs-type">Num</span><span> </span><a href="#local-6989586621679092149"><span class="hs-identifier hs-type">a</span></a><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><a href="HBandit.Types.html#ZeroOne"><span class="hs-identifier hs-type">ZeroOne</span></a><span> </span><a href="#local-6989586621679092149"><span class="hs-identifier hs-type">a</span></a><span>
</span><a name="line-33"></a><a name="one"><a href="HBandit.Types.html#one"><span class="hs-identifier">one</span></a></a><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier hs-var">unsafeRefine</span><span> </span><span class="hs-number">1</span><span>
</span><a name="line-34"></a><span>
</span><a name="line-35"></a><span class="hs-comment">-- | @normalizedSum@ sums the `snd` from the tuple list using weights</span><span>
</span><a name="line-36"></a><span class="hs-comment">-- in the `fst`. The result is normalized against the list of `fst`s.</span><span>
</span><a name="line-37"></a><span class="hs-identifier">normalizedSum</span><span> </span><span class="hs-glyph">::</span><span>
</span><a name="line-38"></a><span> </span><span class="hs-special">(</span><span class="hs-identifier hs-type">Ord</span><span> </span><a href="#local-6989586621679092148"><span class="hs-identifier hs-type">a</span></a><span class="hs-special">,</span><span> </span><span class="hs-identifier hs-type">Fractional</span><span> </span><a href="#local-6989586621679092148"><span class="hs-identifier hs-type">a</span></a><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span>
</span><a name="line-39"></a><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><a href="HBandit.Types.html#ZeroOne"><span class="hs-identifier hs-type">ZeroOne</span></a><span> </span><a href="#local-6989586621679092148"><span class="hs-identifier hs-type">a</span></a><span class="hs-special">,</span><span> </span><a href="HBandit.Types.html#ZeroOne"><span class="hs-identifier hs-type">ZeroOne</span></a><span> </span><a href="#local-6989586621679092148"><span class="hs-identifier hs-type">a</span></a><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><a name="line-40"></a><span> </span><a href="HBandit.Types.html#ZeroOne"><span class="hs-identifier hs-type">ZeroOne</span></a><span> </span><a href="#local-6989586621679092148"><span class="hs-identifier hs-type">a</span></a><span>
</span><a name="line-41"></a><a name="normalizedSum"><a href="HBandit.Types.html#normalizedSum"><span class="hs-identifier">normalizedSum</span></a></a><span> </span><a name="local-6989586621679092151"><a href="#local-6989586621679092151"><span class="hs-identifier">l</span></a></a><span> </span><span class="hs-glyph">=</span><span>
</span><a name="line-42"></a><span> </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier hs-var">sum</span><span> </span><span class="hs-special">(</span><span class="hs-identifier hs-var">unrefine</span><span> </span><span class="hs-operator hs-var">.</span><span> </span><span class="hs-identifier hs-var">fst</span><span> </span><span class="hs-operator hs-var">&lt;$&gt;</span><span> </span><a href="#local-6989586621679092151"><span class="hs-identifier hs-var">l</span></a><span class="hs-special">)</span><span> </span><span class="hs-operator hs-var">==</span><span> </span><span class="hs-number">0</span><span>
</span><a name="line-43"></a><span> </span><span class="hs-keyword">then</span><span> </span><a href="HBandit.Types.html#zero"><span class="hs-identifier hs-var">HBandit.Types.zero</span></a><span>
</span><a name="line-44"></a><span> </span><span class="hs-keyword">else</span><span>
</span><a name="line-45"></a><span> </span><span class="hs-identifier hs-var">unsafeRefine</span><span> </span><span class="hs-operator hs-var">$</span><span>
</span><a name="line-46"></a><span> </span><span class="hs-identifier hs-var">sum</span><span>
</span><a name="line-47"></a><span> </span><span class="hs-special">(</span><span> </span><a href="#local-6989586621679092151"><span class="hs-identifier hs-var">l</span></a><span>
</span><a name="line-48"></a><span> </span><span class="hs-operator hs-var">&lt;&amp;&gt;</span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><a name="local-6989586621679092185"><a href="#local-6989586621679092185"><span class="hs-identifier">w</span></a></a><span class="hs-special">,</span><span> </span><a name="local-6989586621679092186"><a href="#local-6989586621679092186"><span class="hs-identifier">v</span></a></a><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier hs-var">unrefine</span><span> </span><a href="#local-6989586621679092185"><span class="hs-identifier hs-var">w</span></a><span> </span><span class="hs-operator hs-var">*</span><span> </span><span class="hs-identifier hs-var">unrefine</span><span> </span><a href="#local-6989586621679092186"><span class="hs-identifier hs-var">v</span></a><span>
</span><a name="line-49"></a><span> </span><span class="hs-special">)</span><span>
</span><a name="line-50"></a><span> </span><span class="hs-operator hs-var">/</span><span> </span><span class="hs-identifier hs-var">sum</span><span> </span><span class="hs-special">(</span><span class="hs-identifier hs-var">unrefine</span><span> </span><span class="hs-operator hs-var">.</span><span> </span><span class="hs-identifier hs-var">fst</span><span> </span><span class="hs-operator hs-var">&lt;$&gt;</span><span> </span><a href="#local-6989586621679092151"><span class="hs-identifier hs-var">l</span></a><span class="hs-special">)</span><span>
</span><a name="line-51"></a><span>
</span><a name="line-52"></a><span class="hs-comment">-- | @normalize x xm@ normalizes @x@ using @xm@. Returns @Nothing@</span><span>
</span><a name="line-53"></a><span class="hs-comment">-- in case the resulting value is not contained in $[0,1]$ .</span><span>
</span><a name="line-54"></a><span class="hs-identifier">normalize</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier hs-type">Double</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier hs-type">Double</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier hs-type">Maybe</span><span> </span><span class="hs-special">(</span><a href="HBandit.Types.html#ZeroOne"><span class="hs-identifier hs-type">ZeroOne</span></a><span> </span><span class="hs-identifier hs-type">Double</span><span class="hs-special">)</span><span>
</span><a name="line-55"></a><a name="normalize"><a href="HBandit.Types.html#normalize"><span class="hs-identifier">normalize</span></a></a><span> </span><a name="local-6989586621679092187"><a href="#local-6989586621679092187"><span class="hs-identifier">v</span></a></a><span> </span><a name="local-6989586621679092188"><a href="#local-6989586621679092188"><span class="hs-identifier">m</span></a></a><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier hs-var">refine</span><span> </span><span class="hs-special">(</span><a href="#local-6989586621679092187"><span class="hs-identifier hs-var">v</span></a><span> </span><span class="hs-operator hs-var">/</span><span> </span><a href="#local-6989586621679092188"><span class="hs-identifier hs-var">m</span></a><span class="hs-special">)</span><span> </span><span class="hs-operator hs-var">&amp;</span><span> </span><span class="hs-glyph">\</span><span class="hs-glyph">case</span><span>
</span><a name="line-56"></a><span> </span><span class="hs-identifier hs-var">Right</span><span> </span><a name="local-6989586621679092189"><a href="#local-6989586621679092189"><span class="hs-identifier">n</span></a></a><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier hs-var">Just</span><span> </span><a href="#local-6989586621679092189"><span class="hs-identifier hs-var">n</span></a><span>
</span><a name="line-57"></a><span> </span><span class="hs-identifier hs-var">Left</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier hs-var">Nothing</span><span>
</span><a name="line-58"></a></pre></body></html>
\ No newline at end of file
<!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><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">-- |</span><span>
</span><a name="line-2"></a><span class="hs-comment">-- Module : HBandit.Util</span><span>
</span><a name="line-3"></a><span class="hs-comment">-- Copyright : (c) 2019, UChicago Argonne, LLC.</span><span>
</span><a name="line-4"></a><span class="hs-comment">-- License : MIT</span><span>
</span><a name="line-5"></a><span class="hs-comment">-- Maintainer : fre@freux.fr</span><span>
</span><a name="line-6"></a><span class="hs-comment">--</span><span>
</span><a name="line-7"></a><span class="hs-comment">-- Utility functions for MAB algorithms.</span><span>
</span><a name="line-8"></a><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">HBandit.Util</span><span>
</span><a name="line-9"></a><span> </span><span class="hs-special">(</span><span> </span><a href="HBandit.Util.html#sampleWL"><span class="hs-identifier hs-var">sampleWL</span></a><span class="hs-special">,</span><span>
</span><a name="line-10"></a><span> </span><span class="hs-special">)</span><span>
</span><a name="line-11"></a><span class="hs-keyword">where</span><span>
</span><a name="line-12"></a><span>
</span><a name="line-13"></a><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Monad.Random</span><span>
</span><a name="line-14"></a><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Protolude</span><span>
</span><a name="line-15"></a><span>
</span><a name="line-16"></a><span class="hs-comment">-- | Samples from a weighted probability distribution.</span><span>
</span><a name="line-17"></a><span class="hs-comment">-- The sum of weights must not be zero.</span><span>
</span><a name="line-18"></a><span class="hs-identifier">sampleWL</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier hs-type">RandomGen</span><span> </span><a href="#local-6989586621679112909"><span class="hs-identifier hs-type">g</span></a><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="hs-identifier hs-type">Double</span><span class="hs-special">,</span><span> </span><a href="#local-6989586621679112910"><span class="hs-identifier hs-type">a</span></a><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><a href="#local-6989586621679112909"><span class="hs-identifier hs-type">g</span></a><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><a href="#local-6989586621679112910"><span class="hs-identifier hs-type">a</span></a><span class="hs-special">,</span><span> </span><a href="#local-6989586621679112909"><span class="hs-identifier hs-type">g</span></a><span class="hs-special">)</span><span>
</span><a name="line-19"></a><a name="sampleWL"><a href="HBandit.Util.html#sampleWL"><span class="hs-identifier">sampleWL</span></a></a><span> </span><a name="local-6989586621679112911"><a href="#local-6989586621679112911"><span class="hs-identifier">weights</span></a></a><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier hs-var">runRand</span><span> </span><span class="hs-special">(</span><span class="hs-identifier hs-var">fromList</span><span> </span><span class="hs-special">(</span><a href="#local-6989586621679112911"><span class="hs-identifier hs-var">weights</span></a><span> </span><span class="hs-operator hs-var">&lt;&amp;&gt;</span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><a name="local-6989586621679113327"><a href="#local-6989586621679113327"><span class="hs-identifier">r</span></a></a><span class="hs-special">,</span><span> </span><a name="local-6989586621679113328"><a href="#local-6989586621679113328"><span class="hs-identifier">x</span></a></a><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><a href="#local-6989586621679113328"><span class="hs-identifier hs-var">x</span></a><span class="hs-special">,</span><span> </span><span class="hs-identifier hs-var">toRational</span><span> </span><a href="#local-6989586621679113327"><span class="hs-identifier hs-var">r</span></a><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><a name="line-20"></a></pre></body></html>
\ No newline at end of file
This diff is collapsed.
var highlight = function (on) {
return function () {
var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
var that = links[i];
if (this.href != that.href) {
continue;
}
if (on) {
that.classList.add("hover-highlight");
} else {
that.classList.remove("hover-highlight");
}
}
}
};
window.onload = function () {
var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
links[i].onmouseover = highlight(true);
links[i].onmouseout = highlight(false);
}
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment