From Python for R users, p151
import scipy.stats as stats
oddsratio, pvalue = stats.fisher_exact([[8, 2], [1, 5]])
print oddsratio,pvalue
# 20.0 0.03496503496503495
# test based on poisson distribution
def sig_test_poisson(x=0.3,mu=0.001):
p=stats.distributions.poisson.pmf(x,mu)
#print "poisson test:",p # work correctly
return p
# test based on negative binomial distribution
def sig_test_nbinom(x=100,n=50,p=0.3):
p=stats.distributions.nbinom.pmf(x,n,p)
#print "nbinom test:",p # work correctly
return p
# two sample distribution test
def ks_2samp(x,y):
p=stats.ks_2samp(x,y)[1]
return p
# two sample rank test
def sig_spearman_corr(x,y):
p=stats.spearmanr(x,y)[0]
return p
def sig_pearson_corr(x,y):
p=stats.pearsonr(x,y)[0]
return p
rvs1 = stats.norm.rvs(loc=5,scale=10,size=500)
rvs2 = stats.norm.rvs(loc=5,scale=10,size=500)
stats.ttest_ind(rvs1,rvs2)
# (0.26833823296239279, 0.78849443369564776)
stats.ttest_ind(rvs1,rvs2, equal_var = False)
# (0.26833823296239279, 0.78849452749500748)