• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Random number generator without duplicates?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Random number generator without duplicates?


  • Subject: Re: Random number generator without duplicates?
  • From: "M.S.R.F. Schonewille" <email@hidden>
  • Date: Wed, 18 Apr 2001 01:04:01 +0200
  • Organization: University of Nijmegen

You almost got it right. If you want statistically correct results, make a list of number from which you want to choose. Shuffle the list and choose from this list ad random. Delete the chosen element from the list and choose again.
Choosing a random number and ignoring it if it has been chosen before is apparently the most popular approach, but it is incorrect. Note that numbered pieces of paper cannot be chosen from a hat, if these numbers are no longer there. So, yo can't throw them away either. There will be a bias, because the probability of choosing a number that has not been chosen before will be reduced. Theoretically, this number will be
reduced to indefinitely close to zero. This means that the expected average of all chosen numbers is no longer equal to the actual average of the original sample. Theoretically, the expected average will be biased negatively, because it is the weighted average of the probabilities and the available elements in the sample. The theoretical probability of the last element to be chosen, may be equal to virtually zero, which
reduces the expected average with an amount that is equal to this last element. So, making a sample, choosing from the sample and deleting the selected elements is the only way to obtain unbiased results.
As a last remark, the "popular" approach will take days, if you want to select from a very large sample. I tried creating a sample of several millions of elements and never got any result :-) I didn't want to ask my grandchildren to finish my research, so I pressed command-period.

Mark


Doug McNutt wrote:

> >How can I get a list of random numbers that does not include any duplicates?
>
> The buzzword for searching is "shuffling". There was an article in Dr. Dobbs Journal about a year ago. You start with an indexed array of integers from 1 to N and move them around at random. It makes a difference whether or not you allow an individual element - a card - to be moved twice. I have a MacPerl script which I have been meaning to update to the Dr. Dobbs recommendations but it works now. if you'd like it - ask.
>
> AppleScript? I don't even know how to typedef an array let alone work with pointers to the elements.
> --
>
> -> From the U S of A, the only socialist country that refuses to admit it. <-
> _______________________________________________
> applescript-users mailing list
> email@hidden
> http://www.lists.apple.com/mailman/listinfo/applescript-users

--

University of Nijmegen
Nijmegen School of Management (FBW)
P.O. Box 9108
6500 HK Nijmegen
The Netherlands

Phone: +31 24 361 15 64
Fax: +31 24 361 23 79
Homepage: http://schonewille.cjb.net


References: 
 >Random number generator without duplicates? (From: email@hidden)
 >Re: Random number generator without duplicates? (From: Doug McNutt <email@hidden>)

  • Prev by Date: Re: zapping gremlins
  • Next by Date: Re: How to script URL Access to post radio buttons?
  • Previous by thread: Re: Random number generator without duplicates?
  • Next by thread: Re: Random number generator without duplicates?
  • Index(es):
    • Date
    • Thread