Skip to content

Package Reference

This part of the project documentation focuses on an information-oriented approach. Use it as a reference for the technical implementation of thediego-utils codebase.

Metrics

Module to analyse and compare distributions.

The functionality is divided into two main types
  • Distribution Comparison: Functionality to compare two distributions.
  • Distribution Analysis: Functionality to analyse a distribution.

ks_test_with_normal(data)

Perform a Kolmogorov-Smirnov test comparing the given data to a normal distribution.

Parameters:

Name Type Description Default
data List[int]

The data to compare.

required

Returns

Tuple[float, float]: KS statistic and two-tailed p-value.
Source code in diego_utils/metrics/distributions.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def ks_test_with_normal(data: List[int]) -> Tuple[float, float]:
    """
    Perform a Kolmogorov-Smirnov test comparing the given data to a normal distribution.

    Args:
        data (List[int]): The data to compare.

    Returns
    -------
        Tuple[float, float]: KS statistic and two-tailed p-value.
    """
    # Convert data to a numpy array
    data = np.array(data)

    # Perform the KS test
    d, p_value = stats.kstest(data, "norm", args=(np.mean(data), np.std(data)))

    return d, p_value