8
$\begingroup$

Tutorials demonstrating simple random sampling, first list the full number of population members (i.e., sampling frame) in a column and then assign a random number from $0$ to $1$ from a uniform distribution to each.

Question: BUT WHY (as shown in this tutorials), before getting a sample (e.g., of $n = 40$) from our sampling frame we must "sort" the sampling frame based on the random numbers for each population member? (What role does sorting etc. play?)

$\endgroup$
4
  • $\begingroup$ The sampling method is to take the $n$ values with the lowest random numbers. You do not have to use the particular sorting method shown: for example you could use something based on RANK() or something based on ` LARGE()` or SMALL() $\endgroup$
    – Henry
    Commented Aug 9, 2020 at 20:32
  • $\begingroup$ The video does shuffle the IDs. Other form of shuffling are possible $\endgroup$
    – Henry
    Commented Aug 9, 2020 at 21:01
  • $\begingroup$ @Henry, I appreciate it if you could specifically clarify: why we sort/order/rank etc. the sampling frame before being able to pick a random sample? What role does sort/order/rank etc. play? $\endgroup$ Commented Aug 9, 2020 at 21:12
  • $\begingroup$ Excel does not have a sample function. But it does have a random number generator. So you can allocate a random number to each value you want to sample from, and then choose those with the smallest (or largest) random numbers as your sample $\endgroup$
    – Henry
    Commented Aug 9, 2020 at 22:18

2 Answers 2

13
$\begingroup$

Sorting a list of objects based on an accompanying set of IID continuous random variables (such as uniform random variables) is equivalent to shuffling those objects into a random order (i.e., by a random permutation). Since the random values are independent continuous random variables, every possible permutation is equally likely, and that is the definition of simple random sampling. This method is used in computer programs that have facilities to create pseudo-random numbers, but do not have an existing sampling function.

$\endgroup$
6
  • 1
    $\begingroup$ This was what I was looking for thanks! $\endgroup$ Commented Aug 9, 2020 at 22:31
  • $\begingroup$ BTW, could we instead of generating our random number from a uniform(0,1), generate our random number from uniform(3,9)? $\endgroup$ Commented Aug 9, 2020 at 22:41
  • 3
    $\begingroup$ You can use any continuous distribution --- the sorting properties are the same (see this related question). $\endgroup$
    – Ben
    Commented Aug 9, 2020 at 23:06
  • $\begingroup$ (One slight complication to this is that computer PRNGs never generate perfectly continuous random variables, since there is a limit to the number of digits for the generated number. So technically there is a possibility of ties, but this hardly ever happens.) $\endgroup$
    – Ben
    Commented Aug 10, 2020 at 22:34
  • $\begingroup$ Let me answer that question with a link. ; ) $\endgroup$
    – Ben
    Commented Aug 10, 2020 at 22:38
2
$\begingroup$

It should be emphasized that you don't need to sort in order to sample. The method given in the tutorial works, but it is extremely inefficient. It basically does $\Theta(n \log n)$ operations for what can be done in $\Theta(1)$.

If you can sample a random floating point number from 0 to 1, you can sample a random integer from 1 to n. And Excel can give you the value in a list at a specific index. You can use that for sampling.

(Note, though, that Excels tends to re-roll all random values whenever you do anything, so you'll want to copy the value of the random index before proceeding.)

$\endgroup$
3
  • $\begingroup$ asymptotic efficiency is rarely an issue in spreadsheets. If you have enough data that you need to worry about the amount of time that sorting will take, then you probably shouldn't be using Excel to analyse them.... And if you have little enough data that you can fit it into excel, why are you sampling them.... making the whole question moot. $\endgroup$
    – James K
    Commented Aug 10, 2020 at 17:05
  • $\begingroup$ @JamesK There are many reasons to sample data small enough to fit in excel. For example, when conducting field investigations that take several weeks each. Even a single-digit number of selections is huge! $\endgroup$ Commented Aug 10, 2020 at 17:31
  • $\begingroup$ @JamesK Even if the actual time of sorting is not noticeable in practice - I find that using such an egregiously inefficient algorithm reflects a fundamental misunderstanding of what sampling is. Such confusion can lead to other errors. Highlighting how the action should be done sheds light on the underlying issues. $\endgroup$ Commented Aug 10, 2020 at 17:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.