#title Python - 비율 검정 [[TableOfContents]] ==== one-sample ==== A중학교에는 100명 중에 45명이 흡연을 한다. 국가 통계를 보니 중학생 흡연율은 35%라고 한다. 같나? {{{ import numpy as np from statsmodels.stats.proportion import proportions_ztest count = np.array([45]) nobs = np.array([100]) val = 0.35 z, p = proportions_ztest(count=count, nobs=nobs, value=val) print(z) print(p) }}} ==== two-sample ==== 복날에 A회사 사람들 300명 중 100명이 삼계탕을 먹었고, B회사 사람들 400명 중 170명이 삼계탕을 먹었다. 비율이 같냐? {{{ import numpy as np from statsmodels.stats.proportion import proportions_ztest count = np.array([100, 170]) nobs = np.array([300, 400]) z, p = proportions_ztest(count=count, nobs=nobs, value=0) print(z) print(p) }}}