<div dir="ltr"><div><div>Also look into Sci-Smalltalk, there are several PRNG there.<br></div>For large integers, we need to construct them by chunk anyway.<br><br>We construct a large X in interval [0,2^N-1], where for example N is a multiple of 32 for simple PRNG.<br></div><div>Then we perform Max * X // (2^N) for generating in interval [0,Max-1].<br></div><div>Some guard must be taken with N &gt; highbit(Max) so as to obtain a fair distribution (uniform).<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-02-12 20:46 GMT+01:00 Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It seems like it only has csprngs. I see there one based on the Fortuna algorithm, and one based on SHA1 in counter mode.<span class="HOEnZb"><font color="#888888"><br>
<br>
Levente</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Thu, 12 Feb 2015, Levente Uzonyi wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
IIRC it has a mersenne twister (which is a quite common choice for prngs). We should check the implementation and see if it&#39;s efficient enough.<br>
<br>
Levente<br>
<br>
On Thu, 12 Feb 2015, Chris Muller wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Maybe adopt one of the ones from the Cryptography package?<br>
<br>
On Thu, Feb 12, 2015 at 12:52 PM, Levente Uzonyi &lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tue, 10 Feb 2015, Bert Freudenberg wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 10.02.2015, at 15:37, <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
Bert Freudenberg uploaded a new version of Kernel to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/Kernel-bf.899.mcz" target="_blank">http://source.squeak.org/<u></u>trunk/Kernel-bf.899.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Kernel-bf.899<br>
Author: bf<br>
Time: 10 February 2015, 4:37:05.988 pm<br>
UUID: 1cc7d0c6-0a3d-457f-9609-<u></u>fa508d11310e<br>
Ancestors: Kernel-eem.898<br>
<br>
Fix random for Really Large Integers.<br>
<br>
=============== Diff against Kernel-eem.898 ===============<br>
<br>
Item was changed:<br>
 ----- Method: Random&gt;&gt;nextInt: (in category &#39;accessing&#39;) -----<br>
 nextInt: anInteger<br>
        &quot; Answer a random integer in the interval [1, anInteger].<br>
anInteger should be less than 16r80000000. &quot;<br>
<br>
        anInteger strictlyPositive ifFalse: [ self error: &#39;Range must be<br>
positive&#39; ].<br>
+       &quot;avoid Float arithmetic in #next to work with LargeInts&quot;<br>
+       ^ ((seed := self nextValue) asInteger * anInteger // M asInteger)<br>
+ 1!<br>
-       ^ (self next * anInteger) truncated + 1!<br>
</blockquote>
<br>
<br>
<br>
We might want to do something better if anInteger &gt; 16r80000000, because<br>
that&#39;s the maximum number of different random integers we can produce. We<br>
would need to call nextValue twice (or more times) to produce enough<br>
randomness.<br>
</blockquote>
<br>
<br>
Fetching more bits from the generator won&#39;t be better. This generator has 31<br>
bits internal state, so it can&#39;t generate longer random numbers.<br>
We need a better PRNG.<br>
<br>
Levente<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
My fix just solves the immediate problem of running into infinite Floats.<br>
<br>
- Bert -<br>
<br>
<br>
<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br></div>