Apr 10, 2013 at 7:34pm
i wonder how to create a stream of non-repeating random numbers,
eg. if this is the result of the 1st stream of urn values:
2 4 3 1 5 7 6
and this the second stream
5 6 1 3 7 2 4
i want to use the values in groups:
2 4 3
as you can see the 6 in the 3rd group of numbers appears twice. the easiest way to handle a situation
is there an object that obtain non-repeating random number under this circumstances?
thanks for your help , johannes
Apr 11, 2013 at 3:03pm
Anyone asking for a stream of random numbers without repetition is essentially looking for a kind of Markov chain. The [prob] object is the standard general Markov chain object. However, it is designed with first-order Markov chains in mind, and what you’re looking for would need a second-order Markov chain.
The inestimable Xoaz (aka Richard Dudas) built a an abstraction wrapper around [prob] for higher-order Markov chains. It was called [mchain] and I expect it’s now available through the Tools page on this site.
However you try to manage this with factory objects, there will be a bit of work to do, it ain’t just settin’ a parameter. I did build a custom object doing this sort of thing, once upon a time, but I never polished it up for public consumption. Some day, but it’s fairly low down my To-Do list.
Apr 11, 2013 at 5:44pm
Peter, they’re nowhere to be found. Upon googling for Dudas’ abstractions it would seem that they’re offline from ircam as well.
sounded ideal for one of my capers as well.
Apr 11, 2013 at 10:15pm
Richard should be on the forum (he certainly used to be). I hope he won’t mind me suggesting that someone drop him a line expressing interest in mchain.
I have a copy, but it’s really better if you get it directly from the source. Richard may have made some improvements over my (very old) copy.
Apr 12, 2013 at 4:25pm
thanks for pointing to richards abstraction, peter.
i found a nice intro on markov chains in dodgeÂ´s “computer music” book as well as
Apr 12, 2013 at 6:05pm
Apr 14, 2013 at 11:23am
ok, i checked mchain. its a very nice abstraction but not exactly what iam looking for.
from what i understand, with a 2nd order markov chain i can define that the numbers of the first and second state will not appear as a number at the 3rd state. so there will be 0 probability for the first two numbers to be the 3rd and the first to be second value.
what i donÂ´t understand is how to create a markov chain that gives me also a stream of non-repeated numbers from 0 to n-1
any help would be greatly appreciated, j
Apr 14, 2013 at 6:02pm
I never promised a rose garden;
With a 2nd order Markov with (to keep things simple) four states (0, 1, 2, 3), you need to set up a transition matrix like the following (the first column gives the previous two states, the following columns are the probability for the next value).
Extend that for n=whatever: given the previous to states t[-2] = x and t[-1] = y, (xâ‰ y), then the probability of t=z is zero for x and y, otherwise 1/(n-2).
Yes, this turns into masses of typing for large values of n, and this is a special kind of Markov chain where an algorithm can be designed where all you would need to specify is a single parameter. But until someone writes an external object that implements your special case, you’re probably going to have to do it the hard way
Apr 17, 2013 at 11:38pm
here is my 2nd order markov-chain patch using the ftm-library. inspired my peter elseas paper
i add a function that automatically generates the transition-table (that peter mentioned) according to the selected maximum value.
the aim of this patch is to create groups of 3 numbers with no repetitions in it.
– Pasted Max Patch, click to expand. –
Copy all of the following text.Then, in Max, select New From Clipboard.
You must be logged in to reply to this topic.