Hmmm. put randomBytes(8) into sortIV sort lines of myVar by sha1Digest( each & sortIV )
or resetUniqueRandom sort lines of myVar by uniqueRandom( the number of lines of myVar ) -- where resetUniqueRandom and uniqueRandom are custom handlers Dar On May 23, 2013, at 2:11 PM, Björnke von Gierke wrote: > Yes, that is why I myself lean towards a feature request. For example the > following line could tell the engine to make a unique random number for each > of the supplied lines, to not have the problem with lines that come first > getting a higher probability: > > sort theData by random(the number of lines in theData) of each > > On 23.05.2013, at 21:57, Dar Scott wrote: > >> I don't think anybody is claiming that random() does not work. (Some random >> number generators will break with a bad seed, but that is outside the scope >> of discussion.) When Chris thought random() was broken, most people >> suggested he look at his code around the sort. >> >> The problem is that randomly assigning sort values will distort the sort >> because of the handling when sort values are equal. The sort value is >> assigned independently for each line or item. That means some will be the >> same. >> >> In the same sense, if I sorted on length of the item, those items with the >> same length will keep the same order. In this random() case, some will have >> the same randomly selected number. >> >> Large values to random() reduces the distortion. For random(2) and a list >> of 2, the first will be first again 75% of the time. For random(3) and a >> list of 3, it will be first 53% of the time. For random(999999) it seems to >> be first 50% of the time for either of those cases. >> >> I think you do have a point about lists eventually becoming larger than the >> large number. If random does something reasonable with an super large >> number than that might be better. >> >> Dar >> >> >> >> >> >> On May 23, 2013, at 12:54 PM, Björnke von Gierke wrote: >> >>> So much misinformation in this thread :( >>> >>> The random function works! it uses the same code as many other programs to >>> do random stuff. Of course it's using a semi random list, but the >>> technicalities about when random is not random enough does not come into >>> place for sorting lines. >>> >>> sort the lines of theList by random(the number of lines in theList) >>> >>> This too works. there's no need to make an arbitrary large number _BECAUSE >>> IT MIGHT IN SOME CASES DECREASE RANDOMNESS_. Mostly when your variable >>> grows bigger then anticipated, so usually you're fine. But still, don't use >>> arbitrary magic numbers, it's just bad coding habits. >>> >>> As for the original poster: DO NOT SET THE RANDOMSEED!!!! Then your code >>> will start to work as expected, or as erroneous as you coded it ;-) >>> >>> >>> On 23.05.2013, at 03:16, Jacques Hausser wrote: >>> >>>> Chris, I think Randy has put his finger on something: the * is before any >>>> number or letter in the ASCII numeration. I do not know what the random >>>> function uses when randomizing a "set" (I was not even aware of this >>>> possibility) but that could well be the ASCII value(s) of the first >>>> char(s). >>>> >>>> Jacques >>>> >>>> Le 23 mai 2013 à 02:36, Randy Hengst <iowahen...@mac.com> a écrit : >>>> >>>>> Well Chris, I'm sure you've already tried this, but when this kind of >>>>> thing happens to me… in other words, when a script is correct, but the >>>>> results are wrong… I've messed something up later in the script with >>>>> another put statement that overrides it. Maybe the place in the script >>>>> where you've removed the * >>>>> >>>>> My debugging skills are not top notch… So, I'd brute force things and put >>>>> an "answer tPossibleAnswers" after each line to see what is happening… >>>>> and again at the end of the handler. >>>>> >>>>> I'd be interested in what you discover. >>>>> >>>>> be well, >>>>> randy >>>>> ----- >>>>> On May 22, 2013, at 4:34 PM, Chris Sheffield wrote: >>>>> >>>>>> Thanks for the suggestions everyone, but I'm still getting strange >>>>>> results, and I'm beginning to think there's something I'm doing that's >>>>>> affecting use of the random() function. Not really sure what it would be >>>>>> though. Here's my code: >>>>>> >>>>>> set the itemDel to tab >>>>>> put "*" & item 3 of sRecSet into tPossibleAnswers -- correct answer >>>>>> put cr & item 4 of sRecSet after tPossibleAnswers -- distractor 1 >>>>>> put cr & item 5 of sRecSet after tPossibleAnswers -- distractor 2 >>>>>> sort lines of tPossibleAnswers by random(999999) -- randomly re-order >>>>>> the list >>>>>> >>>>>> This app pulls words from a database and presents three possible answers >>>>>> to choose from. The asterisk above is used to identify the correct >>>>>> answer after the sort takes place. It's removed later on. The sort only >>>>>> works randomly one time. After that, the same sort order is used every >>>>>> time, so the correct answer *always* ends up listed first. It doesn't >>>>>> matter if I use a very high number or if I use 'the number of lines of >>>>>> tPossibleAnswers'. Something is very strange. Just as a quick test, I >>>>>> added a button to the card with this inside: >>>>>> >>>>>> put "one" & cr & "two" & cr & "three" into tLines >>>>>> sort lines of tLines by random(the number of lines of tLines) >>>>>> answer tLines >>>>>> >>>>>> This seems to work just fine. Yes, it does mean getting the same order >>>>>> sometimes twice or maybe even three times in a row, but not usually more >>>>>> than that, which would be fine in this case. So I'm not sure what's >>>>>> going on with my actual code. I'm no longer setting the randomSeed or >>>>>> anything like that. >>>>>> >>>>>> The other strange thing is no matter what I try, if I use the random() >>>>>> function or the any keyword in anyway, I get similar results. Something >>>>>> is affecting the "randomness". This is for an iOS app, btw, if that >>>>>> makes any difference to anyone. This might be kind of a dumb thing to >>>>>> do, but the only other thing I can think of would be to add several more >>>>>> lines of data to the three actual possible answers, then sort the whole >>>>>> thing, then somehow filter out everything I added before the sort. With >>>>>> more lines, maybe I'd get better results? >>>>>> >>>>>> Thanks again, >>>>>> Chris >>>>>> >>>>>> On May 22, 2013, at 3:03 PM, Dar Scott <d...@swcp.com> wrote: >>>>>> >>>>>>> I think you are going to get the first line of the original list >>>>>>> (correct answer) about half the time. Does that seem right to you from >>>>>>> what you have seen? The correct answer will be in the first two about >>>>>>> 80% of the time. >>>>>>> >>>>>>> Using the larger argument for random should give you better >>>>>>> proportions. You should get it in the first line a third of the time. >>>>>>> >>>>>>> If you only interested in the first line, there might be some methods >>>>>>> that are clearer and more fun. >>>>>>> >>>>>>> Dar >>>>>>> >>>>>>> >>>>>>> On May 22, 2013, at 11:59 AM, Chris Sheffield wrote: >>>>>>> >>>>>>>> I have a list of three words that I need to be randomly sorted. To >>>>>>>> start with, the first word is the correct answer to a question. I want >>>>>>>> to re-order the list so that the correct answer may be the second or >>>>>>>> third word, and not necessarily the first. How can I do this >>>>>>>> successfully every time? The docs give an example like this: >>>>>>>> >>>>>>>> sort lines of myVar by random(the number of lines of myVar) >>>>>>>> >>>>>>>> But this only seems to work successfully one time. After that, the >>>>>>>> list is always set so the first word is the correct answer. So then I >>>>>>>> tried randomly setting the randomSeed value, since this value is >>>>>>>> supposed to affect the random() function and the any keyword, but this >>>>>>>> didn't seem to make much difference except to change it so either the >>>>>>>> second or third word is *always* the right answer. I need it to be >>>>>>>> more mixed up than that. >>>>>>>> >>>>>>>> So does anyone have a good way to do this? >>>>>>>> >>>>>>>> Thanks, >>>>>>>> Chris >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> Chris Sheffield >>>>>>>> Read Naturally, Inc. >>>>>>>> www.readnaturally.com >>>>>>>> >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> use-livecode mailing list >>>>>>>> use-livecode@lists.runrev.com >>>>>>>> Please visit this url to subscribe, unsubscribe and manage your >>>>>>>> subscription preferences: >>>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode >>>>>>> >>>>>>> >>>>>>> _______________________________________________ >>>>>>> use-livecode mailing list >>>>>>> use-livecode@lists.runrev.com >>>>>>> Please visit this url to subscribe, unsubscribe and manage your >>>>>>> subscription preferences: >>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode >>>>>> >>>>>> _______________________________________________ >>>>>> use-livecode mailing list >>>>>> use-livecode@lists.runrev.com >>>>>> Please visit this url to subscribe, unsubscribe and manage your >>>>>> subscription preferences: >>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode >>>>> >>>>> >>>>> _______________________________________________ >>>>> use-livecode mailing list >>>>> use-livecode@lists.runrev.com >>>>> Please visit this url to subscribe, unsubscribe and manage your >>>>> subscription preferences: >>>>> http://lists.runrev.com/mailman/listinfo/use-livecode >>>> >>>> >>>> _______________________________________________ >>>> use-livecode mailing list >>>> use-livecode@lists.runrev.com >>>> Please visit this url to subscribe, unsubscribe and manage your >>>> subscription preferences: >>>> http://lists.runrev.com/mailman/listinfo/use-livecode >>> >>> >>> -- >>> >>> Use an alternative Dictionary viewer: >>> http://bjoernke.com/bvgdocu/ >>> >>> Chat with other RunRev developers: >>> http://bjoernke.com/chatrev/ >>> >>> >>> >>> _______________________________________________ >>> use-livecode mailing list >>> use-livecode@lists.runrev.com >>> Please visit this url to subscribe, unsubscribe and manage your >>> subscription preferences: >>> http://lists.runrev.com/mailman/listinfo/use-livecode >> >> >> _______________________________________________ >> use-livecode mailing list >> use-livecode@lists.runrev.com >> Please visit this url to subscribe, unsubscribe and manage your subscription >> preferences: >> http://lists.runrev.com/mailman/listinfo/use-livecode > > > -- > > Use an alternative Dictionary viewer: > http://bjoernke.com/bvgdocu/ > > Chat with other RunRev developers: > http://bjoernke.com/chatrev/ > > > > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode