question about "random" selection


    Apr 19 2008 | 7:08 am
    Hello
    Im enquiring about the random selection criteria I am playing with in my patch. Below I will paste the patch so you can clearly see what I am talking about, but what I want my random number generator to do is select a number that isnt already selected... So current I have four different groups with 4 radio buttons. i have a random query going to each which is fine. but what happens is that there is the high chance that becuase there are 4 different randoms they will pick the same numbered radio button... so for instance 1224 or something. so two of the random queries have picked the number 2 in two different groups. i would like something that choses a random number but one that hasnt been chosen so each time the random is requested the radio number is unique within each set.. wow that confusing i hope someone knows what i am on about - see the patch if someone can help me: thanks in advance

    • Apr 19 2008 | 10:05 am
      check the patch below. If you don't want the mxj object you can use 3 [zl mth] objects in combination with [random] but i think it looks better with the java class.
      Anyway... check out also urn if you haven't done so allready. It's not exactly what you need but it is good to know that it exists (for the future)
      george
    • Apr 19 2008 | 12:01 pm
      Basically you want to have different random permutations of the four values 0 1 2 3.
      You can build that with a [urn 4] object, or better still with [lp.crabelms 0 1 2 3] from Litter Power.
      lp.crabelms is the (new! improved!) reincarnation of James McCarthy's orphaned scramble object (do not try to make an anagram of the word crabelms!). It does what the name says: scrambles the elements of a list.
    • Apr 20 2008 | 2:50 am
      thank you for your replies guys! im going to use the shuffle item just for its simplicity and time (havnt got much time to figure stuff out)... thanks heaps! your both champs!
    • Apr 20 2008 | 6:10 pm
      I'm pretty sure that the standard "urn" object is what you're looking for.
      Try [urn 4]. That will do exactly what you're looking for, AND it's a standard object. Doesn't get more efficient than that.
    • Apr 20 2008 | 9:05 pm
      Quote: swieser1 wrote on Sun, 20 April 2008 20:10
      ----------------------------------------------------
      > I'm pretty sure that the standard "urn" object is what you're looking for.
      >
      > Try [urn 4]. That will do exactly what you're looking for, AND it's a standard object. Doesn't get more efficient than that.
      ----------------------------------------------------
      Arguable on two points.
      With urn you have to explicitly send a clear message when the urn runs through its contents. Lp.ernie automatically "refills" its urn without requiring an explicit message.
      Secondly, a solution with urn would require an [uzi 4] rather than simply banging lp.crabelms.
      Proof in the pudding: the lp.crabelms solution was the shortest posted in this thread.
      Finally, crabelms uses an industrial-strength RNG. Urn may be assumed to be using the linear congruence implementation from _Numerical Recipes_ used for the other random objects in the factory Max set. If that's good enough for your purposes, fine. But the Numerical Recipes algorithm is known to have problems if you are generating large numbers of random values.
      There is a time and place for standard objects, but there are some things that can be done more efficiently with a well-crafted 3PO.