Random Number Generation Without Numbers Repeating Twice in a Row

WPPK's icon

Hi, I was wondering if anybody had any ideas on random number generation without repeating any 2 numbers twice in a row. Meaning 1,1 cannot happen but 1, 2, 1 can. I have tried messing around with the Urn object which works, but it needs to be cleared after all numbers are output and that creates a small pause before resetting. I am looking for a way to generate continuously random numbers that don't occur in a row.

I've also tried hooking up Random to Change but if random generates a number twice in a row then there is a pause in output.
I'm trying to avoid that.

Any help is greatly appreciated.

Thanks.

zipb's icon

Have a look at the rtc-lib. Lots of interesting stuff, including anti-
repeat stuff.

Op 1-mei-2008, om 21:06 heeft WPPK het volgende geschreven:

>
> Hi, I was wondering if anybody had any ideas on random number
> generation without repeating any 2 numbers twice in a row. Meaning
> 1,1 cannot happen but 1, 2, 1 can. I have tried messing around
> with the Urn object which works, but it needs to be cleared after
> all numbers are output and that creates a small pause before
> resetting. I am looking for a way to generate continuously random
> numbers that don't occur in a row.
>
> I've also tried hooking up Random to Change but if random
> generates a number twice in a row then there is a pause in output.
> I'm trying to avoid that.
>
> Any help is greatly appreciated.
>
> Thanks.

Anthony Palomba's icon

Or you could use 2 urns, like a double buffer.

WPPK's icon

Right!! Thank you. That'll do it.

Chris Muir's icon

On May 1, 2008, at 12:06 PM, WPPK wrote:
> Hi, I was wondering if anybody had any ideas on random number
> generation without repeating any 2 numbers twice in a row. Meaning
> 1,1 cannot happen but 1, 2, 1 can. I have tried messing around with
> the Urn object which works, but it needs to be cleared after all
> numbers are output and that creates a small pause before resetting.
> I am looking for a way to generate continuously random numbers that
> don't occur in a row.

Reseting urn doesn't cause a pause, in my experience. Here's an
abstraction, called UrnCounter, which is like a counter that counts a
random pattern. Perhaps you could pull some techniques out if it?

Max Patch
Copy patch and select New From Clipboard in Max.

Chris Muir
cbm@well.com    
http://www.xfade.com

WPPK's icon

Thanks. I'll take a look, but the text file seems a bit strange. Is it correct? For Max 5?

Chris Muir's icon

On May 1, 2008, at 2:16 PM, WPPK wrote:
> Thanks. I'll take a look, but the text file seems a bit strange. Is
> it correct? For Max 5?

That's the new (as of 5.0.1) Copy Compressed format.

SImply copy the lines, including the lines:
----------begin_max5_patcher----------
----------end_max5_patcher----------

And do a New From Clipboard in Max.

-C

Chris Muir
cbm@well.com    
http://www.xfade.com

WPPK's icon

Any chance you can put this in a text that 4.6 will open. I can't open it.

Thanks.

Chris Muir's icon

Here it is in Max 4, but only because I had an older version. I think that people sticking with Max 4 are going to be orphans before too long.

Max Patch
Copy patch and select New From Clipboard in Max.

bdc's icon

I would also like to point out that in the Max4 examples folder, in
misc-max-trix/notes-and-pitch/random w_o repeat a patch called urn-jb-
help.pat does this. The same patch is in the Max5 examples, in max-
tricks/random_with_no_repeat.

Brad

On 1-May-08, at 6:46 PM, Chris Muir wrote:

>
> Here it is in Max 4, but only because I had an older version. I
> think that people sticking with Max 4 are going to be orphans before
> too long.
>
>
>
>
>
> --
> Chris Muir
> cbm@well.com    
> http://www.xfade.com
>
>