15.12.2012 Views

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Examples<br />

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

>>> import numpy as np<br />

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

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

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

>>> n1 = 200 # size of first sample<br />

>>> n2 = 300 # size of second sample<br />

different distribution we can reject the null hypothesis since the pvalue is below 1%<br />

>>> rvs1 = stats.norm.rvs(size=n1,loc=0.,scale=1);<br />

>>> rvs2 = stats.norm.rvs(size=n2,loc=0.5,scale=1.5)<br />

>>> ks_2samp(rvs1,rvs2)<br />

(0.20833333333333337, 4.6674975515806989e-005)<br />

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

slightly different distribution we cannot reject the null hypothesis at a 10% or lower alpha since the pvalue at<br />

0.144 is higher than 10%<br />

>>> rvs3 = stats.norm.rvs(size=n2,loc=0.01,scale=1.0)<br />

>>> ks_2samp(rvs1,rvs3)<br />

(0.10333333333333333, 0.14498781825751686)<br />

identical distribution we cannot reject the null hypothesis since the pvalue is high, 41%<br />

>>> rvs4 = stats.norm.rvs(size=n2,loc=0.0,scale=1.0)<br />

>>> ks_2samp(rvs1,rvs4)<br />

(0.07999999999999996, 0.41126949729859719)<br />

mannwhitneyu(x, y, use_continuity=True)<br />

Computes the Mann-Whitney rank test on samples x and y.<br />

Notes<br />

Parameters<br />

x, y : array_like<br />

Array of samples, should be one-dimensional.<br />

use_continuity : bool, optional<br />

Returns<br />

u : float<br />

Whether a continuity correction (1/2.) should be taken into account. Default is True.<br />

The Mann-Whitney statistics.<br />

prob : float<br />

One-sided p-value assuming a asymptotic normal distribution.<br />

Use only when the number of observation in each sample is > 20 and you have 2 independent samples of ranks.<br />

Mann-Whitney U is significant if the u-obtained is LESS THAN or equal to the critical value of U.<br />

This test corrects for ties and by default uses a continuity correction. The reported p-value is for a one-sided<br />

hypothesis, to get the two-sided p-value multiply the returned p-value by 2.<br />

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

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

Saved successfully!

Ooh no, something went wrong!