注意: python 版本太低不行
#!/usr/bin/env python
# coding=utf-8
import numpy as np
from scipy import stats
"""
l1是实验组的广告主价值 arpu 值,l2是对照组的
这是另一个版本(其中每个值为 test-base 的值)
ttest_rel([0.000395,0.00445,-0.002332,0.000853,0.000757,0.003946,0.003782,0.006273,0.005644], [0] * 9)
python 3.9
"""
l1 = [115.1, 115.05, 115.42, 116.27, 117.59, 117.15, 115.87]
l2 = [115.06, 115.01, 115.46, 126.4, 127.58, 127.29, 126.07]
improve_pct = round(np.mean((np.array(l1) - np.array(l2)) / np.array(l2)) * 100, 2)
statistic, p_value = stats.ttest_ind(l1, l2, alternative='greater')
# 平均提升
print("improve_pct: {}% ".format(improve_pct))
# p 值( p_value < 0.05 才是置信的)
print("p_value: ", p_value)