# Path: segeval/util/math.py
# def mean(values):
#     '''
#     Calculates the mean of a list of numeric values.
# 
#     :param values: List of numeric values.
#     :type values: list
# 
#     :returns: Mean.
#     :rtype: :class:`decimal.Decimal`
#     '''
#     summation = Decimal(0)
#     for value in values:
#         summation += value
#     if len(values) > 0:
#         return summation / len(values)
#     else:
#         return 0
# 
# def std(values):
#     '''
#     Calculates the population standard deviation of a list of numeric values.
# 
#     :param values: List of numeric values.
#     :type values: list
# 
#     :returns: Standard deviation.
#     :rtype: :class:`decimal.Decimal`
#     '''
#     return var(values).sqrt()
# 
# def var(values):
#     '''
#     Calculates the population variance of a list of numeric values.
# 
#     :param values: List of numeric values.
#     :type values: list
# 
#     :returns: Variance.
#     :rtype: :class:`decimal.Decimal`
#     '''
#     mean_value = mean(values)
#     summation = Decimal(0)
#     for value in values:
#         summation += (value - mean_value) ** 2
#     return summation / len(values)
# 
# def stderr(values):
#     '''
#     Calculates the population standard error of the mean of a list of numeric
#     values.
# 
#     :param values: List of numeric values.
#     :type values: list
# 
#     :returns: Standard error of the mean.
#     :rtype: :class:`decimal.Decimal`
#     '''
#     return std(values) / Decimal(len(values)).sqrt()


import unittest
from decimal import Decimal
from segeval.util.math import mean, std, var, stderr
'''
Tests some math related utility functions.

.. moduleauthor:: Chris Fournier <chris.m.fournier@gmail.com>
'''
from __future__ import absolute_import


class TestMath(unittest.TestCase):

    '''
    Math utlity function tests.
    '''

    def test_mean(self):
        '''
        Tests population mean.
        '''
        self.assertEqual(5, mean([2, 4, 4, 4, 5, 5, 7, 9]))

    def test_mean_0(self):
        '''
        Tests population mean.
        '''

# Path: segeval/util/math.py
# def mean(values):
#     '''
#     Calculates the mean of a list of numeric values.
# 
#     :param values: List of numeric values.
#     :type values: list
# 
#     :returns: Mean.
#     :rtype: :class:`decimal.Decimal`
#     '''
#     summation = Decimal(0)
#     for value in values:
#         summation += value
#     if len(values) > 0:
#         return summation / len(values)
#     else:
#         return 0
# 
# def std(values):
#     '''
#     Calculates the population standard deviation of a list of numeric values.
# 
#     :param values: List of numeric values.
#     :type values: list
# 
#     :returns: Standard deviation.
#     :rtype: :class:`decimal.Decimal`
#     '''
#     return var(values).sqrt()
# 
# def var(values):
#     '''
#     Calculates the population variance of a list of numeric values.
# 
#     :param values: List of numeric values.
#     :type values: list
# 
#     :returns: Variance.
#     :rtype: :class:`decimal.Decimal`
#     '''
#     mean_value = mean(values)
#     summation = Decimal(0)
#     for value in values:
#         summation += (value - mean_value) ** 2
#     return summation / len(values)
# 
# def stderr(values):
#     '''
#     Calculates the population standard error of the mean of a list of numeric
#     values.
# 
#     :param values: List of numeric values.
#     :type values: list
# 
#     :returns: Standard error of the mean.
#     :rtype: :class:`decimal.Decimal`
#     '''
#     return std(values) / Decimal(len(values)).sqrt()


# Path: segeval/util/math_test.py
import unittest
from decimal import Decimal
from segeval.util.math import mean, std, var, stderr

'''
Tests some math related utility functions.

.. moduleauthor:: Chris Fournier <chris.m.fournier@gmail.com>
'''
from __future__ import absolute_import


class TestMath(unittest.TestCase):

    '''
    Math utlity function tests.
    '''

    def test_mean(self):
        '''
        Tests population mean.
        '''
        self.assertEqual(5, mean([2, 4, 4, 4, 5, 5, 7, 9]))

    def test_mean_0(self):
        '''
        Tests population mean.
        '''

        self.assertEqual(0, mean([]))