largest number for random
Apr 18, 2013 at 7:45pm
largest number for randomby trial and error, I’ve found that the largest number returned by random is 2**31 – 1. (2147483647) is this correct? thanks Arun 

Apr 18, 2013 at 8:10pm
That is correct. 

Apr 18, 2013 at 8:46pm
BTW, The sadam Library (see http://cycling74.com/forums/topic.php?id=42930 ) contains an object ( HTH, 

Apr 19, 2013 at 9:53am
No real need for trialanderror. Max uses 32bit integers and 32bit floating point. Integers are in 2scomplement, so the largest value that can be represented is (2^31)1. This holds for [random], [counter], [number], etc. etc. and for every other object dealing with ints. And this is true for both Mac OS and Windows (always has been). The only exception is Max 6.1 in 64bit mode, and here a bit of trialanderror may prove interesting. As I understand the SDK, Max uses 64bit atoms (ie, 64bit ints, floats, pointers, etc.) But that doesn’t necessarily mean that absolutely all objects will automatically be working with 64bit structures internally. In particular, the algorithm for [random] that DDZ documented here many years ago is intrinsically 32bit (note: the algorithm would easily handle unsigned 32bit ints, but Max interprets all ints as signed). It would be necessary to modify the calculations performed inside [random] to generate values outside the 32bit range. A quick look seems to indicate that, in Max 6.1 under 64bit mode, it is possible to feed [random] a range parameter larger than (2^31)1. However, it’s not immediately clear what this is doing! Take a look (don’t forget to set Max 6.1 to 64bit mode, what happens in 32bit mode is perfectly clear and a little bit boring): – Pasted Max Patch, click to expand. –
Copy all of the following text.Then, in Max, select New From Clipboard.


Apr 20, 2013 at 8:27pm
isnt it interesting, that the highest possible random number can be foreseen exactly. one would exspect that it is randomly changing over time. 

Apr 21, 2013 at 11:18am
All random number generators have some parameters. Range is only the most common (after distribution, which is also moreorless constant for [random]). The thing with [random 2147483647] is that you’re going to have to wait an awfully long time the highest value to come out (which, btw, is 2147483646… one less than the range). And just how long you’re going to have to wait is unpredictable (or, at least, very difficult to foresee). 

Apr 21, 2013 at 12:57pm
true randomness would be when you ask a computer to perform [random 5] – and 1300 years earlier no apple pie were baked in an airplane tunnel. 

Apr 21, 2013 at 2:04pm
No, that’s the punchline to “how many surrealists does it take to change a lightbulb?” True randomness is when the most compact way to describe a sequence is the sequence itself. (Martin Gardner, Mathematical Carnival, 1977) 

Apr 21, 2013 at 4:24pm
auch nicht schlecht. 

Apr 22, 2013 at 2:25am
There are many algorithms for random number generators. What algorithm does Max use? 

Apr 22, 2013 at 8:27am
David Zicarelli posted that [random] simply used the Linear Congruence algorithm as implemented in Numerical Recipes. This was many years ago, but there is no particular reason why this should have changed (although, as mentioned earlier, the 64bit environment might be a motivation to update). Yes, the Numerical Recipes implementation is a weak RNC (deterministic loworder bits, correlations in higher dimensions) but it is apparently deemed “good enough” for use in Max/MSP. In case you don’t know this, there are much stronger RNCs implemented in the Litter Power Package, as well as pretty much every random number distribution known to humankind. 
You must be logged in to reply to this topic.