def s2(nj, sj2, M):
    """
    Overall variance for the binned data. The s2 statistic (equation 2 of
    Stellingwerf, 1978).

    Args:
        nj (array): Number of data points per sample/bin (j = 1 to M).
        sj2 (array): Variance of each sample/bin (j = 1 to M).
        M (int): Number of samples/bins.

    Returns:
        The overall variance of the samples/bins.

    """
    return sum((nj - 1) * sj2) / (sum(nj) - M)
