2. Statistical Hypothesis Testing: Student's t-test for Batch Comparison
When changing raw material suppliers or modifying tableting machine speeds, quality control departments must prove that the new formulation batch exhibits identical drug content compared to reference standards. The two-sample independent Student's t-test evaluates whether the difference in mean assay between two batches is statistically significant or merely due to random experimental variance.
Using SciPy to execute an independent two-sample t-test at 95% confidence level (alpha = 0.05).
from scipy import stats
import numpy as np
# Assay percentages across 10 sample tablets from Supplier A and Supplier B
supplier_a = np.array([99.4, 98.8, 100.2, 99.1, 99.8, 100.5, 98.9, 99.6, 100.1, 99.3])
supplier_b = np.array([98.9, 99.2, 99.0, 98.7, 99.5, 99.1, 98.8, 99.3, 99.0, 98.9])
t_stat, p_val = stats.ttest_ind(supplier_a, supplier_b)
print(f"Supplier A Mean: {np.mean(supplier_a):.2f}% | Supplier B Mean: {np.mean(supplier_b):.2f}%")
print(f"Calculated t-statistic: {t_stat:.4f}")
print(f"Two-tailed p-value: {p_val:.4f}")
if p_val > 0.05:
print("Conclusion: No statistically significant difference between suppliers (p > 0.05). Both are interchangeable.")
else:
print("Conclusion: Statistically significant difference observed (p <= 0.05).")- Null Hypothesis ($H_0$): Mean drug content of Batch A is identical to Batch B ($\mu_A = \mu_B$).
- Alternative Hypothesis ($H_1$): Mean drug content differs significantly ($\mu_A \ne \mu_B$).
- Significance Threshold ($p < 0.05$): If p-value is less than 0.05, reject null hypothesis.
Student's t-test से यह साबित किया जाता है कि नए सप्लायर या नई मशीन से बनी दवाओं की गुणवत्ता में कोई सांख्यिकीय अंतर (Significant Difference) नहीं है।