statistics Package

statistics Package

Statistics shortcut functions

maidenhair.statistics.average(x)[source]

Return a numpy array of column average. It does not affect if the array is one dimension

Parameters:

x : ndarray

A numpy array instance

Returns:

ndarray :

A 1 x n numpy array instance of column average

Examples

>>> a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>> np.array_equal(average(a), [2, 5, 8])
True
>>> a = np.array([1, 2, 3])
>>> np.array_equal(average(a), [1, 2, 3])
True
maidenhair.statistics.confidential_interval(x, alpha=0.98)[source]

Return a numpy array of column confidential interval

Parameters:

x : ndarray

A numpy array instance

alpha : float

Alpha value of confidential interval

Returns:

ndarray :

A 1 x n numpy array which indicate the each difference from sample average point to confidential interval point

maidenhair.statistics.mean(x)[source]

Return a numpy array of column mean. It does not affect if the array is one dimension

Parameters:

x : ndarray

A numpy array instance

Returns:

ndarray :

A 1 x n numpy array instance of column mean

Examples

>>> a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>> np.array_equal(mean(a), [2, 5, 8])
True
>>> a = np.array([1, 2, 3])
>>> np.array_equal(mean(a), [1, 2, 3])
True
maidenhair.statistics.median(x)[source]

Return a numpy array of column median. It does not affect if the array is one dimension

Parameters:

x : ndarray

A numpy array instance

Returns:

ndarray :

A 1 x n numpy array instance of column median

Examples

>>> a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>> np.array_equal(median(a), [2, 5, 8])
True
>>> a = np.array([1, 2, 3])
>>> np.array_equal(median(a), [1, 2, 3])
True
maidenhair.statistics.simple_moving_average(x, n=10)[source]

Calculate simple moving average

Parameters:

x : ndarray

A numpy array

n : integer

The number of sample points used to make average

Returns:

ndarray :

A 1 x n numpy array instance

maidenhair.statistics.simple_moving_matrix(x, n=10)[source]

Create simple moving matrix.

Parameters:

x : ndarray

A numpy array

n : integer

The number of sample points used to make average

Returns:

ndarray :

A n x n numpy array which will be useful for calculating confidentail interval of simple moving average

maidenhair.statistics.standard_deviation(x)[source]

Return a numpy array of column standard deviation

Parameters:

x : ndarray

A numpy array instance

Returns:

ndarray :

A 1 x n numpy array instance of column standard deviation

Examples

>>> a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>> np.testing.assert_array_almost_equal(
...     standard_deviation(a),
...     [0.816496, 0.816496, 0.816496])
>>> a = np.array([1, 2, 3])
>>> np.testing.assert_array_almost_equal(
...     standard_deviation(a),
...     0.816496)
maidenhair.statistics.variance(x)[source]

Return a numpy array of column variance

Parameters:

x : ndarray

A numpy array instance

Returns:

ndarray :

A 1 x n numpy array instance of column variance

Examples

>>> a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>> np.testing.assert_array_almost_equal(
...     variance(a),
...     [0.666666, 0.666666, 0.666666])
>>> a = np.array([1, 2, 3])
>>> np.testing.assert_array_almost_equal(
...     variance(a),
...     0.666666)