15.12.2012 Views

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

vs1 = stats.norm.rvs(loc=5,scale=10,size=500)<br />

>>> rvs2 = stats.norm.rvs(loc=5,scale=10,size=500)<br />

>>> stats.ttest_ind(rvs1,rvs2)<br />

(0.26833823296239279, 0.78849443369564765)<br />

test with sample with different means<br />

>>> rvs3 = stats.norm.rvs(loc=8,scale=10,size=500)<br />

>>> stats.ttest_ind(rvs1,rvs3)<br />

(-5.0434013458585092, 5.4302979468623391e-007)<br />

ttest_rel(a, b, axis=0)<br />

Calculates the T-test on TWO RELATED samples of scores, a and b.<br />

SciPy Reference Guide, Release 0.8.dev<br />

This is a two-sided test for the null hypothesis that 2 related or repeated samples have identical average (expected)<br />

values.<br />

Notes<br />

Parameters<br />

a, b : sequence of ndarrays<br />

The arrays must have the same shape.<br />

axis : int, optional, (default axis=0)<br />

Axis can equal None (ravel array first), or an integer (the axis over which to operate<br />

on a and b).<br />

Returns<br />

t : float or array<br />

t-statistic<br />

prob : float or array<br />

two-tailed p-value<br />

Examples for the use are scores of the same set of student in different exams, or repeated sampling from the<br />

same units. The test measures whether the average score differs significantly across samples (e.g. exams). If<br />

we observe a large p-value, for example greater than 0.05 or 0.1 then we cannot reject the null hypothesis of<br />

identical average scores. If the p-value is smaller than the threshold, e.g. 1%, 5% or 10%, then we reject the<br />

null hypothesis of equal averages. Small p-values are associated with large t-statistics.<br />

Examples<br />

>>> from <strong>scipy</strong> import stats<br />

>>> np.random.seed(12345678) # fix random seed to get same numbers<br />

>>> rvs1 = stats.norm.rvs(loc=5,scale=10,size=500)<br />

>>> rvs2 = (stats.norm.rvs(loc=5,scale=10,size=500) +<br />

... stats.norm.rvs(scale=0.2,size=500))<br />

>>> stats.ttest_rel(rvs1,rvs2)<br />

(0.24101764965300962, 0.80964043445811562)<br />

>>> rvs3 = (stats.norm.rvs(loc=8,scale=10,size=500) +<br />

... stats.norm.rvs(scale=0.2,size=500))<br />

>>> stats.ttest_rel(rvs1,rvs3)<br />

(-3.9995108708727933, 7.3082402191726459e-005)<br />

kstest(rvs, cdf, args=(), N=20, alternative=’two_sided’, mode=’approx’, **kwds)<br />

Perform the Kolmogorov-Smirnov test for goodness of fit<br />

3.18. Statistical functions (<strong>scipy</strong>.stats) 657

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!