Hi,
Does anyone knows how to get the random object working without repeating numbers? I mean, for instance, if the random range is 5 I want to get a different number each time.
Cheers,
Enrique
hi, there is an object called shuffle in the motex-library, maybe that`s what you want. marius.
----- Original Message ----- From: "Enrique Franco" enrique.franco@ul.ie To: pd-list@iem.kug.ac.at Sent: Thursday, November 28, 2002 2:19 PM Subject: [PD] Random without repeating numbers
Hi,
Does anyone knows how to get the random object working without repeating numbers? I mean, for instance, if the random range is 5 I want to get a different number each time.
Cheers,
Enrique
-- Tel: +353-61-202741 Fax: +353-61-202734 Room CS2-036, Interaction Design Centre CSIS Building University of Limerick Limerick Ireland
http://www.ul.ie/~idc/ http://www.iua.upf.es/~ffranco
PD-list mailing list PD-list@iem.kug.ac.at http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-list
On Thu, 28 Nov 2002, Enrique Franco wrote:
Hi,
Does anyone knows how to get the random object working without repeating numbers? I mean, for instance, if the random range is 5 I want to get a different number each time.
Look at the example-patch #8 for my k_cext plugin. After the first line, insert the following: srand(time(NULL)); And there you have it. :)
On Thu, 28 Nov 2002, Kjetil S. Matheussen wrote:
On Thu, 28 Nov 2002, Enrique Franco wrote:
Hi,
Does anyone knows how to get the random object working without repeating numbers? I mean, for instance, if the random range is 5 I want to get a different number each time.
Look at the example-patch #8 for my k_cext plugin. After the first line, insert the following: srand(time(NULL)); And there you have it. :)
No, this is not true. Sorry, I probably misunderstood what you ment.
Hola Enrique, list!
maybe just this??
#N canvas 177 273 522 316 10; #X obj 134 55 random 5; #X obj 134 31 bng 15 250 50 0 empty empty empty 0 -6 32 8 -262144 -1 -1; #X obj 147 77 t f b; #X obj 190 148 ==; #X obj 189 171 sel 1; #X obj 189 193 bng 15 250 50 0 empty empty empty 0 -6 32 8 -262144 -1 -1; #X obj 219 193 bng 15 250 50 0 empty empty empty 0 -6 32 8 -262144 -1 -1; #X obj 143 117 v new; #X obj 281 110 v old; #X text 175 206 same; #X text 213 208 differ; #X obj 220 228 v new; #X floatatom 220 251 5 0 0; #X obj 281 53 loadbang; #X msg 281 78 1; #X obj 137 96 t b f; #X connect 0 0 2 0; #X connect 1 0 0 0; #X connect 2 0 15 0; #X connect 2 1 8 0; #X connect 3 0 4 0; #X connect 4 0 5 0; #X connect 4 1 6 0; #X connect 5 0 1 0; #X connect 6 0 11 0; #X connect 7 0 3 0; #X connect 8 0 3 1; #X connect 11 0 12 0; #X connect 11 0 8 0; #X connect 13 0 14 0; #X connect 14 0 8 0; #X connect 15 0 7 0; #X connect 15 1 7 0;
cheers Ivan
At 13:19 +0000 28/11/02, Enrique Franco wrote:
Hi,
Does anyone knows how to get the random object working without repeating numbers? I mean, for instance, if the random range is 5 I want to get a different number each time.
Cheers,
Enrique
-- Tel: +353-61-202741 Fax: +353-61-202734 Room CS2-036, Interaction Design Centre CSIS Building University of Limerick Limerick Ireland
http://www.ul.ie/~idc/ http://www.iua.upf.es/~ffranco
PD-list mailing list PD-list@iem.kug.ac.at http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-list
On Thu, 28 Nov 2002, Enrique Franco wrote:
Does anyone knows how to get the random object working without repeating numbers? I mean, for instance, if the random range is 5 I want to get a different number each time.
If you want sequences of five different numbers from 0 to 4, then you can start with the list "0 1 2 3 4", pick a random valid position in that list and remove the number at that position. That gives you equal access to the 5*4*3*2*1=120 possibilities.
If instead you just want that two consecutive numbers never be the same; then you always keep the previous number (P), and you use 4 as the range, you pick a single random number (R), and you compute R+(R>=P). The trick is that >= is an indicatrix, which means it's worth 1 if the condition is true, and 0 if it's false; and adding that indicatrix to the number itself will cause the previous number to be skipped as a possibility.
e.g. P=2, R's might be 0,1,2,3, then R>=P might be 0,0,1,1, then R+(R>=P) might be 0,1,3,4, and there you go, 2 is skipped.
You will also need the [t] object to route R into >= before +.
Mathieu Bouchard http://artengine.ca/matju
Maybe I'm missing something here, or it's already been said, but
couldn't you just set up a really simple patch to compare the output of [random] with its previous output. If new==old then bang the random again, if new!=old then pass it through.
. . David McCallum . Music wants to be free . http://mentalfloss.ca/sintheta/ .
On Thu, 28 Nov 2002, Enrique Franco wrote:
Hi,
Does anyone knows how to get the random object working without repeating numbers? I mean, for instance, if the random range is 5 I want to get a different number each time.
Cheers,
Enrique
-- Tel: +353-61-202741 Fax: +353-61-202734 Room CS2-036, Interaction Design Centre CSIS Building University of Limerick Limerick Ireland
http://www.ul.ie/~idc/ http://www.iua.upf.es/~ffranco
PD-list mailing list PD-list@iem.kug.ac.at http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-list
Hi, David N G McCallum hat gesagt: // David N G McCallum wrote:
Maybe I'm missing something here, or it's already been said, but couldn't you just set up a really simple patch to compare the output of [random] with its previous output. If new==old then bang the random again, if new!=old then pass it through.
That's what I thought at first glance, too, but as randomness goes, it is possible, that you get a lot of equal numbers after another and that would stop your flow of numbers. Mathieu's solution is a very elegant algorithm, I didn't know before, but I'll remember that one now.
BTW (going off topic now):
I think it was a swiss scientist, who tested how "random" humans behave. He rolled a dice, and test persons were told to guess the result without seeing the dice.
The humans unintentionally tried to avoid repeating numbers. Subconsciously they must think, that "true randomness" excludes repeating results.
Of course it doesn't.
Frank Barknecht _ ______footils.org__
On Thu, 28 Nov 2002, Frank Barknecht wrote:
David N G McCallum hat gesagt: // David N G McCallum wrote:
Maybe I'm missing something here, or it's already been said, but couldn't you just set up a really simple patch to compare the output of [random] with its previous output. If new==old then bang the random again, if new!=old then pass it through.
That's what I thought at first glance, too, but as randomness goes, it is possible, that you get a lot of equal numbers after another and that would stop your flow of numbers.
If you can afford to do N retries without desyncing your patch, and the probability of a good number is 80%, then the probability of a desync will be 20%^N. For example, for N=10, that's 1 out of about 10 million. That's if your uniform generator [random] is uniform enough -- if not, then strange things may happen.
Mathieu's solution is a very elegant algorithm, I didn't know before, but I'll remember that one now.
Thanks =)
I think it was a swiss scientist, who tested how "random" humans behave. He rolled a dice, and test persons were told to guess the result without seeing the dice. The humans unintentionally tried to avoid repeating numbers. Subconsciously they must think, that "true randomness" excludes repeating results. Of course it doesn't.
I remember a prof asking half of the class to throw a coin 100 times and note the results. And the other half to fake them. He was then trying to figure out which ones were faked just by looking at the sheet. His criterion was that real results typically include 6 times the same value in a row (TTTTTT or HHHHHH) while faked results typically avoid those.
Mathieu Bouchard http://artengine.ca/matju
Hi Enrique and list,
I once made an object called 'urn'. It's an urn selection model, i.e. you'll get random numbers without repetition until the urn is empty. I think I'll include it in the next maxlib release... for now you'll find it here: http://www.akustische-kunst.org/puredata/maxlib/urn.zip (includes Win binaries but makefile for Linux & OS X is provided)
Olaf
Enrique Franco schrieb:
Hi,
Does anyone knows how to get the random object working without repeating numbers? I mean, for instance, if the random range is 5 I want to get a different number each time.
Cheers,
Enrique
-- Tel: +353-61-202741 Fax: +353-61-202734 Room CS2-036, Interaction Design Centre CSIS Building University of Limerick Limerick Ireland
http://www.ul.ie/~idc/ http://www.iua.upf.es/~ffranco
PD-list mailing list PD-list@iem.kug.ac.at http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-list
Hi again and sorry for self replay, but I just found that there's also a 'urn' in Krzysztof's cyclone library....
Olaf
Olaf Matthes schrieb:
Hi Enrique and list,
I once made an object called 'urn'. It's an urn selection model, i.e. you'll get random numbers without repetition until the urn is empty. I think I'll include it in the next maxlib release... for now you'll find it here: http://www.akustische-kunst.org/puredata/maxlib/urn.zip (includes Win binaries but makefile for Linux & OS X is provided)
Olaf
hi Olaf,
looks like we have both made a mess, because there is another one in zexy... Namespaces or not, such proliferation is a bad thing.
Do not know what to do. Removing cyclone's urn from cyclone would not be nice either -- it is quite a popular object among the maxers, and I guess my algo is faster then yours and zexy's.
(Of course, it is barely tested, so might be totally broken, just like anything in cyclone. There has been no cyclone-related feedback yet... quite depressing...)
Krzysztof
Olaf Matthes wrote:
Hi again and sorry for self replay, but I just found that there's also a 'urn' in Krzysztof's cyclone library....
...
I once made an object called 'urn'. It's an urn selection model, i.e. you'll
[Krzysztof Czaja]->[Re: [PD] Random without repeating numbers]->[02-11-30 15:29]
|looks like we have both made a mess, because there is another one |in zexy... Namespaces or not, such proliferation is a bad thing. | |Do not know what to do. Removing cyclone's urn from cyclone would |not be nice either -- it is quite a popular object among the |maxers, and I guess my algo is faster then yours and zexy's. | |(Of course, it is barely tested, so might be totally broken, just |like anything in cyclone. There has been no cyclone-related |feedback yet... quite depressing...)
dont get depressed. no feedbakc means it works. ;)
|Olaf Matthes wrote: | > Hi again and sorry for self replay, but I just found that there's also a 'urn' | > in Krzysztof's cyclone library.... |... | >>I once made an object called 'urn'. It's an urn selection model, i.e. you'll
(Of course, it is barely tested, so might be totally broken, just like anything in cyclone. There has been no cyclone-related feedback yet... quite depressing...)
Well, I've been using some of the objects quite regularly for the last days and I must say I'm a satisfied customer. Allow me to do some more testing before commenting more extensively. 1 point already: there is also a gate in IEMLIB, which does something different (actually it's a spigot clone).
mik
Hi
( 02.11.28 13:19 +0000 ) Enrique Franco:
I mean, for instance, if the random range is 5 I want to get a different number each time.
But that's not random!!
If you are a programmer, it's probably [near] trivial to write a numeric generator to meet your needs. If not, you'll need to befriend one ...
On Fri, 29 Nov 2002, .--- ... wrote:
( 02.11.28 13:19 +0000 ) Enrique Franco:
I mean, for instance, if the random range is 5 I want to get a different number each time.
But that's not random!!
Yes it's random, but it's not uniform random. It's a Markov chain with a probability matrix of:
0 ¼ ¼ ¼ ¼
¼ 0 ¼ ¼ ¼
¼ ¼ 0 ¼ ¼
¼ ¼ ¼ 0 ¼
¼ ¼ ¼ ¼ 0
which is an all-ones matrix minus the identity matrix (and then divided by 4 for standardization...)
Mathieu Bouchard http://artengine.ca/matju
Hi
( 02.11.28 13:19 +0000 ) Enrique Franco:
I mean, for instance, if the random range is 5 I want to get a different number each time.
On Fri, 29 Nov 2002, .--- ... wrote:
But that's not random!!
( 02.11.29 11:14 -0500 ) Mathieu Bouchard:
It's a Markov chain with a probability matrix of:
Then that's not random!
"Almost always, such numbers are also required to be independent, so that there are no correlations between successive numbers." http://mathworld.wolfram.com/RandomNumber.html
I *am* splitting hairs here. I know that. This discussion has little to do with the needs of the pd user anymore. [maybe I'm just being too deterministic in my definition of randomness ... ]
But that's not random!!
( 02.11.29 11:14 -0500 ) Mathieu Bouchard:
It's a Markov chain with a probability matrix of:
Then that's not random!
"Almost always, such numbers are also required to be independent, so that there are no correlations between successive numbers." http://mathworld.wolfram.com/RandomNumber.html
This page does NOT give a general mathematical or statistical definition of randomness, but rather discusses a specific type of randomness, often associated with generating pseudo random numbers (uniform or other distribution such as normal) on a computer. It is perfectly legitimate to have correlations among successive items in random number sequences, and to still call this a random sequence. There are many cases in science (for example, Markov Chain Monte Carlo algorithms) where this is used to great effect, and in music, it is very easy to imagine where correlated sequences can produce musical effects that are more interesting than purely random sequences. Also, notice that the definition says "Almost always", NOT "always"!
Lawrence
Instead of looking for the perfect random generation algorithm, I'd rather use some analog noise generator and sample it's output.
Here's the result of a quick search on google: http://www.ciphersbyritter.com/NOISE/NOISRC.HTM http://www.rdlnet.com/stng1.htm http://islab.oregonstate.edu/koc/ece679cahd/s2002/morrison.pdf http://rngresearch.com/xrng/
-- Marc
I just found that both Intel i810 and AMD 768 chipsets have an integrated hardware RNG for cryptography, with modules for Linux (i810_rng and amd768_rng).
I like the quote from http://www.cryptography.com/resources/whitepapers/IntelRNG.pdf : "Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin. John Von Neumann (1951)"
-- Marc
Le sam 30/11/2002 à 12:49, Marc Lavallée a écrit :
Instead of looking for the perfect random generation algorithm, I'd rather use some analog noise generator and sample it's output.
Here's the result of a quick search on google: http://www.ciphersbyritter.com/NOISE/NOISRC.HTM http://www.rdlnet.com/stng1.htm http://islab.oregonstate.edu/koc/ece679cahd/s2002/morrison.pdf http://rngresearch.com/xrng/
-- Marc
PD-list mailing list PD-list@iem.kug.ac.at http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-list
.--- ... schrieb:
( 02.11.28 13:19 +0000 ) Enrique Franco:
I mean, for instance, if the random range is 5 I want to get a different number each time.
But that's not random!!
It's a kind of randomness: It's like drawing a number out of an urn, without putting back the drawn number. Repeat as you like.
Frank Barknecht