Returns (weights, means, variances), where:

        weights
          ndarray of number of samples per key
        means
          computed mean value for each key
        variances
          computed variance for each key

def finish (self, keyset, mask=True):
        """Returns (weights, means, variances), where:

        weights
          ndarray of number of samples per key
        means
          computed mean value for each key
        variances
          computed variance for each key

        """
        n_us = len (self._keymap)
        # By definition (for now), wt >= 1 everywhere, so we don't need to
        # worry about div-by-zero.
        wt_us = self._m0[:n_us]
        mean_us = self._m1[:n_us] / wt_us
        var_us = self._m2[:n_us] / wt_us - mean_us**2

        n_them = len (keyset)
        wt = np.zeros (n_them, dtype=self._m0.dtype)
        mean = np.empty (n_them, dtype=self._m1.dtype)
        mean.fill (np.nan)
        var = np.empty_like (mean)
        var.fill (np.nan)

        us_idx = []
        them_idx = []

        for them_i, key in enumerate (keyset):
            us_i = self._keymap[key]
            if us_i < n_us:
                them_idx.append (them_i)
                us_idx.append (us_i)
            # otherwise, we must not have seen that key

        wt[them_idx] = wt_us[us_idx]
        mean[them_idx] = mean_us[us_idx]
        var[them_idx] = var_us[us_idx]

        if mask:
            m = ~np.isfinite (mean)
            mean = np.ma.MaskedArray (mean, m)
            var = np.ma.MaskedArray (var, m)

        self._m0 = self._m1 = self._m2 = None
        self._keymap.clear ()

        return wt, mean, var