Binomial Test: Setup, Critical Regions, and Real-World Analysis
The binomial test checks hypotheses about the success probability in a series of independent Bernoulli trials. The test statistic is the number of successes Y ~ Bin(n, p), where n is the sample size and p is the success probability.
We'll use the Amazon Top 50 Bestselling Books dataset (2009–2019): 550 books labeled as Fiction or Non-Fiction. Null hypothesis H₀: p = 0.5 (equal shares of fiction and non-fiction). Alternatives: H₁: p > 0.5 (right-tailed), p < 0.5 (left-tailed), or p ≠ 0.5 (two-tailed).
Significance level α = 0.05. Test statistic: T = ∑ I{x_i = 1}, where x_i = 1 for Fiction.
Hypothesis Setup and Errors
Hypothesis testing involves the null H₀ and alternative H₁. Decisions: reject H₀ or fail to reject.
Error types:
- Type I error (α): Rejecting a true H₀ (false positive).
- Type II error (β): Failing to reject a false H₀ (false negative).
| Scenario | H₀ True | H₀ False |
|----------|---------|----------|
| Reject H₀ | α | 1−β (power) |
| Fail to Reject H₀ | 1−α | β |
α = 0.05 is the standard tradeoff.
Test Statistic Distribution
Each trial is Bernoulli: X_i ~ Bern(p), with P(X=1) = p (Fiction) and P(X=0) = 1−p.
Y = ∑ X_i ~ Bin(n=550, p), where P(Y=k) = C(550,k) × p^k × (1-p)^(550-k).
Under H₀ (p=0.5), the distribution is symmetric.
Critical Regions
Right-tailed (H₁: p > 0.5):
Critical region K = {k ≥ r}, where r is the smallest integer such that P(Y ≥ r | H₀) ≤ 0.05.
r = 295: ∑_{i=295}^{550} C(550,i) × 0.5^{550} ≤ 0.05.
Left-tailed (H₁: p < 0.5):
K = {k ≤ l}, where l is the largest integer such that P(Y ≤ l | H₀) ≤ 0.05.
l = 255.
Two-tailed (H₁: p ≠ 0.5):
K = {k ≤ 241} ∪ {k ≥ 309}, with each tail probability ≤ 0.025.
Data Processing and Observed Statistic
import pandas as pd
df = pd.read_csv("bestsellers with categories.csv")
bins = df['Genre'].value_counts().tolist()
print(bins) # [310, 240]
Fiction: 310, Non-Fiction: 240. Observed statistic t_obs = 310.
Interpreting Results
Right-tailed: 310 > 295 → Reject H₀ (p > 0.5).
Left-tailed: 310 > 255 → Fail to reject H₀.
Two-tailed: 310 ≥ 309 → Reject H₀ (p ≠ 0.5).
Conclusion: Fiction dominates the bestseller list (56.4% vs. 43.6%).
Key Takeaways
- Binomial test suits binary outcomes with fixed n.
- Critical values for Bin(550, 0.5) at α=0.05: 295 (right), 255 (left), 241/309 (two-tailed).
- t_obs=310 rejects H₀: p=0.5 in favor of p>0.5.
- Type I error (α=0.05) is controlled; power depends on true p.
- For large n, normal approximations work, but exact tests are best.
— Editorial Team
No comments yet.