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 />

This performs a test of the distribution G(x) of an observed random variable against a given distribution F(x).<br />

Under the null hypothesis the two distributions are identical, G(x)=F(x). The alternative hypothesis can be either<br />

‘two_sided’ (default), ‘less’ or ‘greater’. The KS test is only valid for continuous distributions.<br />

Notes<br />

Parameters<br />

rvs : string or array or callable<br />

string: name of a distribution in <strong>scipy</strong>.stats<br />

array: 1-D observations of random variables<br />

callable: function to generate random variables, requires keyword argument size<br />

cdf : string or callable<br />

string: name of a distribution in <strong>scipy</strong>.stats, if rvs is a string then cdf can evaluate to<br />

False or be the same as rvs callable: function to evaluate cdf<br />

args : tuple, sequence<br />

N : int<br />

distribution parameters, used if rvs or cdf are strings<br />

sample size if rvs is string or callable<br />

alternative : ‘two_sided’ (default), ‘less’ or ‘greater’<br />

defines the alternative hypothesis (see explanation)<br />

mode : ‘approx’ (default) or ‘asymp’<br />

Returns<br />

D : float<br />

defines the distribution used for calculating p-value<br />

‘approx’ : use approximation to exact distribution of test statistic<br />

‘asymp’ : use asymptotic distribution of test statistic<br />

KS test statistic, either D, D+ or D-<br />

p-value : float<br />

one-tailed or two-tailed p-value<br />

In the one-sided test, the alternative is that the empirical cumulative distribution function of the random variable<br />

is “less” or “greater” than the cumulative distribution function F(x) of the hypothesis, G(x)=F(x).<br />

Examples<br />

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

>>> import numpy as np<br />

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

>>> x = np.linspace(-15,15,9)<br />

>>> kstest(x,’norm’)<br />

(0.44435602715924361, 0.038850142705171065)<br />

658 Chapter 3. Reference

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

Saved successfully!

Ooh no, something went wrong!