Debian Codegraph @

docs/source/array-stats.rst

raw
1 Stats
2 =====
3
4 Dask Array implements a subset of the `scipy.stats`_ package.
5
6 Statistical Functions
7 ---------------------
8
9 You can calculate various measures of an array including skewness, kurtosis, and arbitrary moments.
10
11 .. code-block:: python
12
13 >>> from dask.array import stats
14 >>> rng = da.random.default_rng()
15 >>> x = rng.beta(1, 1, size=(1000,), chunks=10)
16 >>> k, s, m = [stats.kurtosis(x), stats.skew(x), stats.moment(x, 5)]
17 >>> dask.compute(k, s, m)
18 (1.7612340817172787, -0.064073498030693302, -0.00054523780628304799)
19
20
21 Statistical Tests
22 -----------------
23
24 You can perform basic statistical tests on Dask arrays.
25 Each of these tests return a ``dask.delayed`` wrapping one of the scipy ``namedtuple``
26 results.
27
28
29 .. code-block:: python
30
31 >>> rng = da.random.default_rng()
32 >>> a = rng.uniform(size=(50,), chunks=(25,))
33 >>> b = a + rng.uniform(low=-0.15, high=0.15, size=(50,), chunks=(25,))
34 >>> result = stats.ttest_rel(a, b)
35 >>> result.compute()
36 Ttest_relResult(statistic=-1.5102104380013242, pvalue=0.13741197274874514)
37
38 .. _scipy.stats: https://docs.scipy.org/doc/scipy-0.19.0/reference/stats.html