A random sampling distribution shows how a statistic (like the mean) varies when we take many samples from the same population. It helps us understand the spread and behavior of that statistic.
Click to reveal answer
beginner
How do you generate random samples using numpy?
You can use numpy's functions like numpy.random.choice() to pick random samples from data, or numpy.random.normal() to generate samples from a normal distribution.
Click to reveal answer
beginner
Why do we use many samples to create a sampling distribution?
Using many samples helps us see the range and pattern of the statistic's values. This shows how much the statistic can change just by chance.
Click to reveal answer
intermediate
What does the Central Limit Theorem say about sampling distributions?
It says that if you take many samples of a large enough size, the distribution of the sample means will look like a normal (bell-shaped) curve, no matter the original data shape.
Click to reveal answer
beginner
How can you visualize a sampling distribution in Python?
You can collect many sample statistics (like means) in a list or array, then use a histogram plot (e.g., with matplotlib) to see the shape and spread of the sampling distribution.
Click to reveal answer
Which numpy function can generate random samples from a normal distribution?
Anumpy.random.shuffle()
Bnumpy.random.choice()
Cnumpy.random.normal()
Dnumpy.random.randint()
✗ Incorrect
numpy.random.normal() generates samples from a normal distribution. The others serve different purposes.
What does a sampling distribution represent?
AThe distribution of a statistic from many samples
BThe distribution of the original data
CThe distribution of a single sample
DThe distribution of random numbers
✗ Incorrect
A sampling distribution shows how a statistic (like the mean) varies across many samples.
According to the Central Limit Theorem, the sampling distribution of the mean will be approximately normal if:
APopulation is normal
BSample size is large
CSample size is small
DPopulation is uniform
✗ Incorrect
The Central Limit Theorem states that with a large sample size, the sampling distribution of the mean is approximately normal regardless of population shape.
Which of these is NOT a reason to use random sampling?
ATo estimate population parameters
BTo get a representative sample
CTo reduce bias
DTo guarantee the sample mean equals population mean
✗ Incorrect
Random sampling helps reduce bias and estimate parameters but does not guarantee the sample mean equals the population mean.
What Python library is commonly used to visualize sampling distributions?
Amatplotlib
Bnumpy
Cpandas
Dscipy
✗ Incorrect
matplotlib is commonly used to create histograms and plots to visualize sampling distributions.
Explain what a random sampling distribution is and why it is important in statistics.
Think about how sample means change when you take many samples.
You got /3 concepts.
Describe how you would use numpy to create a sampling distribution of the mean from a dataset.
Imagine picking many small groups from your data and finding their averages.
You got /4 concepts.
Practice
(1/5)
1. What does the numpy.random.choice function do in random sampling?
easy
A. It selects random elements from a given array or list.
B. It generates random numbers from a normal distribution.
C. It creates a sequence of numbers with equal spacing.
D. It calculates the mean of a dataset.
Solution
Step 1: Understand the purpose of numpy.random.choice
This function is used to randomly pick elements from an input array or list, optionally with replacement.
Step 2: Compare with other options
Options A, B, and C describe different numpy functions or operations unrelated to random selection from an array.
Final Answer:
It selects random elements from a given array or list. -> Option A
Quick Check:
numpy.random.choice = random selection [OK]
Hint: Remember: choice picks from arrays, normal generates bell curve numbers [OK]
Common Mistakes:
Confusing choice with normal distribution generator
Thinking choice creates sequences
Assuming choice calculates statistics
2. Which of the following is the correct syntax to generate 5 samples from a binomial distribution with 10 trials and success probability 0.3 using numpy?
easy
A. numpy.binomial(10, 0.3, 5)
B. numpy.random.binomial(10, 0.3, size=5)
C. numpy.random.binomial(size=5, 10, 0.3)
D. numpy.random.binomial(5, 10, 0.3)
Solution
Step 1: Recall the numpy binomial function signature
The correct syntax is numpy.random.binomial(n, p, size) where n is number of trials, p is success probability, and size is number of samples.
Step 2: Check each option
numpy.random.binomial(10, 0.3, size=5) matches the correct order and uses the keyword size. numpy.binomial(10, 0.3, 5) misses .random. numpy.random.binomial(size=5, 10, 0.3) mixes keyword size=5 followed by positionals, causing SyntaxError. numpy.random.binomial(5, 10, 0.3) swaps parameters incorrectly.
Final Answer:
numpy.random.binomial(10, 0.3, size=5) -> Option B
The code sets a random seed for reproducibility, then generates 3 samples from a normal distribution with mean 5 and standard deviation 2.
Step 2: Run or recall the output
Using seed 0, the samples generated are [8.53, 5.8, 6.96] after rounding to 2 decimals.
Final Answer:
[8.53 5.8 6.96] -> Option D
Quick Check:
Seed 0 normal samples = [8.53 5.8 6.96] [OK]
Hint: Use seed for fixed output, then round to compare [OK]
Common Mistakes:
Ignoring seed causes different outputs
Rounding incorrectly
Mixing mean and scale parameters
4. Identify the error in this code snippet that tries to sample 4 values from a uniform distribution between 0 and 1:
import numpy as np
samples = np.random.uniform(low=0, high=1, size=4)
print(samples)
medium
A. There is no error; the code runs correctly.
B. The parameters low and high are reversed.
C. The function name should be random.uniform without numpy prefix.
D. The size parameter must be a tuple, not an integer.
Solution
Step 1: Review the numpy uniform function syntax
np.random.uniform(low, high, size) is the correct way to generate samples from a uniform distribution.
Step 2: Check the code correctness
The code uses correct function name, parameter order, and size as integer for 1D array. It will run without error and print 4 random values between 0 and 1.
Final Answer:
There is no error; the code runs correctly. -> Option A
Quick Check:
Uniform sampling syntax correct = There is no error; the code runs correctly. [OK]
Hint: Check function name and parameter order carefully [OK]
Common Mistakes:
Confusing numpy.random.uniform with Python's random.uniform
Swapping low and high values
Using tuple for size unnecessarily
5. You want to simulate rolling a fair six-sided die 1000 times and count how many times the number 4 appears. Which numpy code correctly performs this simulation?
hard
A. rolls = np.random.choice([1,2,3,4,5,6], size=1000)
count_4 = np.sum(rolls == 4)