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.

Notes<br />

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

We can use this test, if we observe two independent samples from the same or different population, e.g. exam<br />

scores of boys and girls or of two ethnic groups. The test measures whether the average (expected) value differs<br />

significantly across samples. If we observe a large p-value, for example larger than 0.05 or 0.1, then we cannot<br />

reject the null hypothesis of identical average scores. If the p-value is smaller than the threshold, e.g. 1%, 5%<br />

or 10%, then we reject the null hypothesis of equal averages.<br />

Examples<br />

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

>>> import numpy as np<br />

>>> #fix seed to get the same result<br />

>>> np.random.seed(12345678)<br />

test with sample with identical means<br />

>>> rvs1 = 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_onesamp(a, popmean)<br />

Calculates the T-test for the mean of ONE group of scores a.<br />

This is a two-sided test for the null hypothesis that the expected value (mean) of a sample of independent<br />

observations is equal to the given population mean, popmean.<br />

Parameters<br />

a : array_like<br />

sample observation<br />

popmean : float or array_like<br />

expected value in null hypothesis, if array_like than it must have the same shape as<br />

a excluding the axis dimension<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).<br />

Returns<br />

t : float or array<br />

t-statistic<br />

prob : float or array<br />

two-tailed p-value<br />

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

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

Saved successfully!

Ooh no, something went wrong!