Untitled
unknown
plain_text
2 years ago
1.3 kB
9
Indexable
# Membuat fungsi uji statistik
def CheckHypotesis(Successes1,Successes2, Trials1, Trials2, Alpha = 0.05):
# proporsi keberhasilan di kelompok pertama:
P1 = Successes1/Trials1
# proporsi keberhasilan di kelompok kedua:
P2 = Successes2/Trials2
# proporsi keberhasilan dalam dataset gabungan:
PCombined = (Successes1 + Successes2) / (Trials1 + Trials2)
# perbedaan antara proporsi dataset
Difference = P1 - P2
# menghitung statistik dalam standar deviasi dari distribusi normal baku
ZValue = Difference / mth.sqrt(PCombined * (1 - PCombined) * (1/Trials1 + 1/Trials2))
# mengatur distribusi normal baku (rata-rata 0, standar deviasi 1)
Distr = st.norm(0, 1)
Pvalue = (1 - Distr.cdf(abs(ZValue))) * 2
print('p-value: ', Pvalue)
if (Pvalue < Alpha):
print("Menolak hipotesis nol: terdapat perbedaan yang signifikan di antara proporsinya")
else:
print("Gagal untuk menolak hipotesis nol: tidak ada alasan untuk mempertimbangkan bahwa proporsinya berbeda")
# Melakukan uji statistik
CheckHypotesis(
UserPerGroup.loc['MainScreenAppear',246],
UserPerGroup.loc['MainScreenAppear',247],
UserPerEksperiment.loc[246],
UserPerEksperiment.loc[247],
)Editor is loading...