<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Zemyla,<div class=""><br class=""></div><div class="">It’s fully documented in the haddocks which I have temporarily put here: <a href="https://htmlpreview.github.io/?https://raw.githubusercontent.com/idontgetoutmuch/random/haddock-preview/doc/index.html" class="">https://htmlpreview.github.io/?https://raw.githubusercontent.com/idontgetoutmuch/random/haddock-preview/doc/index.html</a>. There was a link to them in the announcement but maybe I should have highlighted it a bit more.</div><div class=""><br class=""></div><div class="">Specifically suppose you love permuted congruential generators then</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">data PCGen = PCGen !Word64 !Word64</div><div class=""><br class=""></div><div class="">stepGen :: PCGen -> (Word32, PCGen)</div><div class="">stepGen (PCGen state inc) = let</div><div class=""> newState = state * 6364136223846793005 + (inc .|. 1)</div><div class=""> xorShifted = fromIntegral (((state `shiftR` 18) `xor` state) `shiftR` 27) :: Word32</div><div class=""> rot = fromIntegral (state `shiftR` 59) :: Word32</div><div class=""> out = (xorShifted `shiftR` (fromIntegral rot)) .|. (xorShifted `shiftL` fromIntegral ((-rot) .&. 31))</div><div class=""> in (out, PCGen newState inc)</div><div class=""><br class=""></div><div class="">instance RandomGen PCGen where</div><div class=""> genWord32 = stepGen</div><div class=""> split _ = error "PCG is not splittable”</div></blockquote><br class=""></div><div class="">And if you prefer a monadic style interface:</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">> (/ 1000) $ sum $ runStateGen_ (PCGen 17 29) $ \g -> replicateM 1000 $ uniformRM (0.0, 1.0) g</blockquote><blockquote type="cite" class=""><br class=""></blockquote><blockquote type="cite" class="">0.508595082944005</blockquote></div><div class=""><br class=""></div><div class="">HTH - let me know if you have any other questions.</div><div class=""><br class=""><div class="">
<div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Dominic Steinitz</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a href="mailto:dominic@steinitz.org" class="">dominic@steinitz.org</a></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a href="http://idontgetoutmuch.org" class="">http://idontgetoutmuch.org</a></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Twitter: @idontgetoutmuch</div></div>
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On 26 May 2020, at 23:47, Zemyla <<a href="mailto:zemyla@gmail.com" class="">zemyla@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="auto" class="">And can you explain how to take an existing RNG and write it in this new format?</div><br class=""></div></blockquote></div><br class=""></div></body></html>