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.

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

Examples<br />

t-statistic<br />

prob : float or array<br />

two-tailed p-value<br />

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

>>> import numpy as np<br />

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

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

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

test if mean of random sample is equal to true mean, and different mean. We reject the null hypothesis in the<br />

second case and don’t reject it in the first case<br />

>>> stats.ttest_1samp(rvs,5.0)<br />

(array([-0.68014479, -0.04323899]), array([ 0.49961383, 0.96568674]))<br />

>>> stats.ttest_1samp(rvs,0.0)<br />

(array([ 2.77025808, 4.11038784]), array([ 0.00789095, 0.00014999]))<br />

examples using axis and non-scalar dimension for population mean<br />

>>> stats.ttest_1samp(rvs,[5.0,0.0])<br />

(array([-0.68014479, 4.11038784]), array([ 4.99613833e-01, 1.49986458e-04]))<br />

>>> stats.ttest_1samp(rvs.T,[5.0,0.0],axis=1)<br />

(array([-0.68014479, 4.11038784]), array([ 4.99613833e-01, 1.49986458e-04]))<br />

>>> stats.ttest_1samp(rvs,[[5.0],[0.0]])<br />

(array([[-0.68014479, -0.04323899],<br />

[ 2.77025808, 4.11038784]]), array([[ 4.99613833e-01, 9.65686743e-01],<br />

[ 7.89094663e-03, 1.49986458e-04]]))<br />

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

Calculates the T-test for the means of TWO INDEPENDENT samples of scores.<br />

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

values.<br />

Parameters<br />

a, b : sequence of ndarrays<br />

The arrays must have the same shape, except in the dimension corresponding to axis<br />

(the first, by default).<br />

axis : int, optional<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 />

692 Chapter 3. Reference

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

Saved successfully!

Ooh no, something went wrong!