Use a script to perform a simple statistical experiment.
To help us discuss these questions, let's create two identical groups of subjects:
G1 = ( 88, 90, 79, 82, 99, 105, 91, 86, 74, 101, 80, 96 ). G2 = ( 88, 90, 79, 82, 99, 105, 91, 86, 74, 101, 80, 96 ).If we select five values from each group at random we might come up with:
G1 Sample = ( 90, 82, 105, 74, 80 ). Sample Mean: 86 G2 Sample = ( 88, 82, 99, 101, 86 ). Sample Mean: 91NOTE: sample means rounded to nearest whole
The actual average for each group is 89. So, you can see that random sampling doesn't guarantee that our samples will be very representative of our actual groups. In fact, we could wind up with random samples like this:
G1 Sample = ( 99, 105, 91, 101, 96 ) Sample Mean: 98 G2 Sample = ( 79, 82, 74, 80, 86 ) Sample Mean: 80Although the odds aren't very high that we will wind up with random samples yielding extremes (especially if we are dealing with large populations and sample sizes), there is always a possibility that this could happen. So, random sampling may not be very reliable if our sample size is small, but as our sample size increases the reliability of random sampling increases.
Random Sampling Script
Consider the following Python script which illustrates the reliability of random sampling:
Also pay attention to the import statement and the line in which random.randint(a,b) gets called.
ASSIGNMENT:
Present the results to this activity on a web page.
Run the Python script shown above ten times. Redirect the output to a file so that it can be easily reformatted into an HTML page. To redirect you do this: