# 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()


from segeval.util.math import mean, std, var, stderr
from itertools import combinations
                # Handle permutation
                if permuted and not has_two_datasets:
                    entry_parts = list(prefix)
                    entry_parts.extend([label, str(n), str(m)])
                    entry = ','.join(entry_parts)
                    if return_parts:
                        label_pairs[entry] = \
                            fnc_metric(segs_n, segs_m, **fnc_kwargs)
                    else:
                        label_pairs[entry] = fnc_metric(segs_n, segs_m,
                                                        **fnc_kwargs)
            # Add all
            for entry, pair in label_pairs.items():
                pairs[entry] = pair
            # Erase
            label_pairs = dict()
    # Parse
    has_two_datasets = dataset_b is not None
    __per_group__(tuple(), dataset_a, dataset_b, has_two_datasets)
    # Return mean, std dev, and variance
    return pairs


def summarize(pairs):
    '''
    Takes a list of values and returns the mean, standard deviation, variance, standard error, and number of values.

    :param pairs: List of numerical values
    :type pairs: list
    '''

# 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/compute.py
from segeval.util.math import mean, std, var, stderr
from itertools import combinations

                # Handle permutation
                if permuted and not has_two_datasets:
                    entry_parts = list(prefix)
                    entry_parts.extend([label, str(n), str(m)])
                    entry = ','.join(entry_parts)
                    if return_parts:
                        label_pairs[entry] = \
                            fnc_metric(segs_n, segs_m, **fnc_kwargs)
                    else:
                        label_pairs[entry] = fnc_metric(segs_n, segs_m,
                                                        **fnc_kwargs)
            # Add all
            for entry, pair in label_pairs.items():
                pairs[entry] = pair
            # Erase
            label_pairs = dict()
    # Parse
    has_two_datasets = dataset_b is not None
    __per_group__(tuple(), dataset_a, dataset_b, has_two_datasets)
    # Return mean, std dev, and variance
    return pairs


def summarize(pairs):
    '''
    Takes a list of values and returns the mean, standard deviation, variance, standard error, and number of values.

    :param pairs: List of numerical values
    :type pairs: list
    '''

    return mean(pairs.values()), std(pairs.values()), var(pairs.values()), \