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.

1.9.4 Comparing two samples<br />

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

In the following, we are given two samples, which can come either from the same or from different distribution, and<br />

we want to test whether these samples have the same statistical properties.<br />

Comparing means<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.54890361750888583, 0.5831943748663857)<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 />

(-4.5334142901750321, 6.507128186505895e-006)<br />

Kolmogorov-Smirnov test for two samples ks_2samp<br />

For the example where both samples are drawn from the same distribution, we cannot reject the null hypothesis since<br />

the pvalue is high<br />

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

(0.025999999999999995, 0.99541195173064878)<br />

In the second example, with different location, i.e. means, we can reject the null hypothesis since the pvalue is below<br />

1%<br />

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

(0.11399999999999999, 0.0027132103661283141)<br />

1.10 Multi-dimensional image processing (ndimage)<br />

1.10.1 Introduction<br />

Image processing and analysis are generally seen as operations on two-dimensional arrays of values. There are however<br />

a number of fields where images of higher dimensionality must be analyzed. Good examples of these are medical<br />

imaging and biological imaging. numpy is suited very well for this type of applications due its inherent multidimensional<br />

nature. The <strong>scipy</strong>.ndimage packages provides a number of general image processing and analysis<br />

functions that are designed to operate with arrays of arbitrary dimensionality. The packages currently includes functions<br />

for linear and non-linear filtering, binary morphology, B-spline interpolation, and object measurements.<br />

1.10. Multi-dimensional image processing (ndimage) 57

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

Saved successfully!

Ooh no, something went wrong!