def samples_are_normal(*samples, **options):
"""Test whether each sample differs from a normal distribution.
Use both Shapiro-Wilk test and D'Agostino and Pearson's test
to test the null hypothesis that the sample is drawn from a
normal distribution.
Returns:
List of tuples (is_normal(bool),(statistic(float),pvalue(float)).
"""
alpha = options.get('alpha', 0.05)
results = []
for sample in samples:
(_, shapiro_pvalue) = shapiro_result = shapiro(sample)
(_, normaltest_pvalue) = normaltest_result = normaltest(sample)
results.append((
not (normaltest_pvalue < alpha and shapiro_pvalue < alpha),
shapiro_result,
normaltest_result
))
return results
评论列表
文章目录