home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.programming      Programming issues that transcend langua      57,431 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 55,651 of 57,431   
   Malcolm McLean to Ben Bacarisse   
   Re: Partial shuffle   
   27 Mar 22 12:19:20   
   
   From: malcolm.arthur.mclean@gmail.com   
      
   On Sunday, 27 March 2022 at 20:09:56 UTC+1, Ben Bacarisse wrote:   
   > Ben Bacarisse  writes:   
   >   
   > > Malcolm McLean  writes:   
   > >   
   > >> You have a list of candidates, ranked by score. You want to try them   
   > >> out in order, with the better candidates being tried first. However   
   > >> you don't want the process to be deterministic - each run should yield   
   > >> a separate order. And you want even low-ranked candidates to have some   
   > >> chance of being tried early.   
   > >>   
   > >> Is there a partial sort / partial shuffle which can achieve this?   
   > >   
   > > Let me check is I know what you mean. You have a list of words with   
   > > scores   
   > >   
   > > 12 apple   
   > > 10 cat   
   > > 9 dog   
   > > 8 egg   
   > > 5 fox   
   > >   
   > > and you want a quasi-sort that might just (but very very rarely)   
   > > produce   
   > >   
   > > 5 fox   
   > > 8 egg   
   > > 9 dog   
   > > 10 cat   
   > > 12 apple   
   > >   
   > > but will produce these orderings much more frequently:   
   > >   
   > > 12 apple 10 cat 10 cat   
   > > 9 dog 9 dog 12 apple   
   > > 10 cat 12 apple 8 egg   
   > > 8 egg 8 egg 5 fox   
   > > 5 fox 5 fox 9 dog   
   > >   
   > > ? First thought. Have a random field, r, that is chosen from a normal   
   > > distribution prior to each sort. Then sort by score+r. By adjusting   
   > > the distribution's parameters, you will get different probabilities of   
   > > re-arrangement from almost none (with, say, mean=0, sdev=0.1) to chaotic   
   > > when mean=1000 sdev=10000.   
   > First thought was too fast! You don't really need to change the mean.   
   > 0 will do just fine. Changing the standard deviation will change the   
   > degree of mixing.   
   >   
   My thinking was on the lines of sorting the list, then doing a shuffle.   
   However instead of using a uniform distribution to pick the element   
   to swap with, us a triangular one, or  a triangle on top of a rectangle.   
   The distribution is at a maximum at 0 and at a minimum at 1.0.   
      
   That avoids needing to add a field. Also, it's maybe easier to control.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca