English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2 answers

You use the random number generator to choose items from your list in a 'random' sample.

For example:

You need a list of 10 people selected at random from a list of 100.

You would have an array with one name per slot, and an associated flag variable, and you would run through a loop, getting a random number from 1 to 100. Check the flag variable, if it's not set, increment a counter by 1 , set the flag, and get another number. When your counter hits 10, quit the loop, and check each flag variable, printing the name if it's been set.

2007-03-22 20:25:36 · answer #1 · answered by edward_otto@sbcglobal.net 5 · 0 0

People tend to form patterns, even when, or maybe especially when, they are trying not to. This can sometimes bias sampling and lead to erroneous results. By using a random number generator we can set up unpredictable sampling intervals.

2007-03-23 03:35:55 · answer #2 · answered by Helmut 7 · 0 0

fedest.com, questions and answers