def summarize_one_branch_samples()

in src/mozanalysis/bayesian_stats/__init__.py [0:0]


def summarize_one_branch_samples(samples, quantiles=DEFAULT_QUANTILES):
    """Return descriptive statistics for sampled population-level stats.

    Given samples from one or more distributions, calculate some
    quantiles and the mean.

    The intended primary use-case is for calculating credible intervals
    for stats when bootstrapping, or credible intervals around Bayesian
    model parameters; in both cases ``samples`` are from a posterior
    concerning one branch of an experiment.

    Args:
    -----
        samples (pandas.Series or pandas.DataFrame): Samples over which
            to compute the mean and quantiles.
        quantiles (list, optional): The quantiles to compute - a good
            reason to override the defaults would be when Bonferroni
            corrections are required.

    Returns:
    --------
        If ``samples`` is a Series, then returns a pandas Series;
        the index contains the stringified ``quantiles`` plus
        ``'mean'``.

        If ``samples`` is a DataFrame, then returns a pandas DataFrame;
        the columns contain the stringified ``quantiles`` plus
        ``'mean'``. The index matches the columns of ``samples``.

    """
    if isinstance(samples, pd.DataFrame) or not np.isscalar(samples[0]):
        return _summarize_one_branch_samples_batch(samples, quantiles)
    else:
        return _summarize_one_branch_samples_single(samples, quantiles)