Question 1160809: 1: A population consists of the following three values: 1,3,4,5,6 and 8
a. List all possible samples of size 3 and compute the proportion of the odd numbers in
every sample.
b. Construct a sampling distribution of the sample proportions.
c. Prove the two properties of the sampling distribution of the sample proportions.
Answer by CPhill(2303) (Show Source):
You can put this solution on YOUR website! ```python
import itertools
import numpy as np
import pandas as pd
population = [1, 3, 4, 5, 6, 8]
N = len(population)
n = 3
# Odd numbers in population: 1, 3, 5 (3 odd numbers)
# Even numbers: 4, 6, 8 (3 even numbers)
# Population proportion of odd numbers P:
odd_count = sum(1 for x in population if x % 2 != 0)
P = odd_count / N
print(f"Population: {population}")
print(f"N: {N}, Odd count: {odd_count}, Population proportion P: {P}")
# All possible samples of size 3 (without replacement):
samples = list(itertools.combinations(population, n))
print(f"Number of samples: {len(samples)}")
sample_proportions = []
for s in samples:
odds = sum(1 for x in s if x % 2 != 0)
p_hat = odds / n
sample_proportions.append((s, odds, p_hat))
df = pd.DataFrame(sample_proportions, columns=['Sample', 'Odd Count', 'p_hat'])
print(df.to_string())
# Sampling distribution
dist = df['p_hat'].value_index if hasattr(df['p_hat'], 'value_index') else df['p_hat'].value_counts().sort_index()
print("\nSampling Distribution:")
print(dist)
# Mean of p_hat:
mean_p_hat = df['p_hat'].mean()
print(f"Mean of p_hat: {mean_p_hat}")
# Variance of p_hat:
# Note: variance of sampling distribution = sum (p_hat - mu_p)^2 * P(p_hat)
var_p_hat = np.mean((df['p_hat'] - mean_p_hat)**2)
print(f"Variance of p_hat: {var_p_hat}")
# Theoretical variance:
# sigma_p_hat^2 = (P * (1 - P) / n) * ((N - n) / (N - 1))
theoretical_var = (P * (1 - P) / n) * ((N - n) / (N - 1))
print(f"Theoretical variance: {theoretical_var}")
```
```text
Population: [1, 3, 4, 5, 6, 8]
N: 6, Odd count: 3, Population proportion P: 0.5
Number of samples: 20
Sample Odd Count p_hat
0 (1, 3, 4) 2 0.666667
1 (1, 3, 5) 3 1.000000
2 (1, 3, 6) 2 0.666667
3 (1, 3, 8) 2 0.666667
4 (1, 4, 5) 2 0.666667
5 (1, 4, 6) 1 0.333333
6 (1, 4, 8) 1 0.333333
7 (1, 5, 6) 2 0.666667
8 (1, 5, 8) 2 0.666667
9 (1, 6, 8) 1 0.333333
10 (3, 4, 5) 2 0.666667
11 (3, 4, 6) 1 0.333333
12 (3, 4, 8) 1 0.333333
13 (3, 5, 6) 2 0.666667
14 (3, 5, 8) 2 0.666667
15 (3, 6, 8) 1 0.333333
16 (4, 5, 6) 1 0.333333
17 (4, 5, 8) 1 0.333333
18 (4, 6, 8) 0 0.000000
19 (5, 6, 8) 1 0.333333
Sampling Distribution:
p_hat
0.000000 1
0.333333 9
0.666667 9
1.000000 1
Name: count, dtype: int64
Mean of p_hat: 0.5000000000000001
Variance of p_hat: 0.049999999999999996
Theoretical variance: 0.049999999999999996
```
The population consists of $N = 6$ values: **$\{1, 3, 4, 5, 6, 8\}$**.
* **Odd numbers:** $1, 3, 5$ (total of $3$ odd numbers)
* **Even numbers:** $4, 6, 8$ (total of $3$ even numbers)
* **Population proportion of odd numbers ($P$):**
$$P = \frac{3}{6} = 0.5$$
The number of possible samples of size $n = 3$ without replacement is:
$$\binom{N}{n} = \binom{6}{3} = \frac{6 \times 5 \times 4}{3 \times 2 \times 1} = 20$$
---
### a. All Possible Samples of Size 3 and Sample Proportions ($\hat{p}$)
| # | Sample | Odd Count | Sample Proportion ($\hat{p}$) |
| --- | --- | --- | --- |
| 1 | $(1, 3, 4)$ | 2 | $2/3 \approx 0.67$ |
| 2 | $(1, 3, 5)$ | 3 | $3/3 = 1.00$ |
| 3 | $(1, 3, 6)$ | 2 | $2/3 \approx 0.67$ |
| 4 | $(1, 3, 8)$ | 2 | $2/3 \approx 0.67$ |
| 5 | $(1, 4, 5)$ | 2 | $2/3 \approx 0.67$ |
| 6 | $(1, 4, 6)$ | 1 | $1/3 \approx 0.33$ |
| 7 | $(1, 4, 8)$ | 1 | $1/3 \approx 0.33$ |
| 8 | $(1, 5, 6)$ | 2 | $2/3 \approx 0.67$ |
| 9 | $(1, 5, 8)$ | 2 | $2/3 \approx 0.67$ |
| 10 | $(1, 6, 8)$ | 1 | $1/3 \approx 0.33$ |
| 11 | $(3, 4, 5)$ | 2 | $2/3 \approx 0.67$ |
| 12 | $(3, 4, 6)$ | 1 | $1/3 \approx 0.33$ |
| 13 | $(3, 4, 8)$ | 1 | $1/3 \approx 0.33$ |
| 14 | $(3, 5, 6)$ | 2 | $2/3 \approx 0.67$ |
| 15 | $(3, 5, 8)$ | 2 | $2/3 \approx 0.67$ |
| 16 | $(3, 6, 8)$ | 1 | $1/3 \approx 0.33$ |
| 17 | $(4, 5, 6)$ | 1 | $1/3 \approx 0.33$ |
| 18 | $(4, 5, 8)$ | 1 | $1/3 \approx 0.33$ |
| 19 | $(4, 6, 8)$ | 0 | $0/3 = 0.00$ |
| 20 | $(5, 6, 8)$ | 1 | $1/3 \approx 0.33$ |
---
### b. Sampling Distribution of the Sample Proportions
Counting the frequencies of each possible proportion value across all 20 samples:
| Sample Proportion ($\hat{p}$) | Frequency ($f$) | Probability $P(\hat{p})$ | $\hat{p} \cdot P(\hat{p})$ | $\hat{p}^2 \cdot P(\hat{p})$ |
| --- | --- | --- | --- | --- |
| $0$ | 1 | $\frac{1}{20} = 0.05$ | $0$ | $0$ |
| $\frac{1}{3}$ | 9 | $\frac{9}{20} = 0.45$ | $\frac{3}{20} = 0.15$ | $\frac{1}{20} = 0.05$ |
| $\frac{2}{3}$ | 9 | $\frac{9}{20} = 0.45$ | $\frac{6}{20} = 0.30$ | $\frac{4}{20} = 0.20$ |
| $1$ | 1 | $\frac{1}{20} = 0.05$ | $\frac{1}{20} = 0.05$ | $\frac{1}{20} = 0.05$ |
| **Total** | **20** | **1.00** | **0.50** | **0.30** |
---
### c. Proof of the Two Properties of the Sampling Distribution
#### Property 1: The mean of the sample proportions equals the population proportion ($\mu_{\hat{p}} = P$)
1. **Observed Mean from Sampling Distribution:**
$$\mu_{\hat{p}} = \sum \hat{p} \cdot P(\hat{p}) = 0(0.05) + \frac{1}{3}(0.45) + \frac{2}{3}(0.45) + 1(0.05) = 0.50$$
2. **Population Proportion ($P$):**
$$P = \frac{3}{6} = 0.50$$
$$\mu_{\hat{p}} = P = 0.50 \quad \checkmark$$
---
#### Property 2: The variance of the sample proportions satisfies the standard error formula with finite population correction
For sampling without replacement from a finite population of size $N$, the theoretical variance is:
$$\sigma_{\hat{p}}^2 = \frac{P(1 - P)}{n} \cdot \left(\frac{N - n}{N - 1}\right)$$
1. **Calculated Variance from Sampling Distribution:**
$$\sigma_{\hat{p}}^2 = \sum \hat{p}^2 \cdot P(\hat{p}) - \mu_{\hat{p}}^2$$
$$\sigma_{\hat{p}}^2 = 0.30 - (0.50)^2 = 0.30 - 0.25 = \mathbf{0.05}$$
2. **Theoretical Formula Evaluation:**
$$\sigma_{\hat{p}}^2 = \frac{(0.5)(1 - 0.5)}{3} \cdot \left(\frac{6 - 3}{6 - 1}\right) = \frac{0.25}{3} \cdot \frac{3}{5} = \frac{0.25}{5} = \mathbf{0.05}$$
$$\sigma_{\hat{p},\text{ observed}}^2 = \sigma_{\hat{p},\text{ theoretical}}^2 = 0.05 \quad \checkmark$$
| |
|