Sample a stratum

        Parameters
        ----------
        pmf : array-like, shape=(n_strata,), optional, default None
            probability distribution to use when sampling from the strata. If
            not given, use the stratum weights.

        replace : bool, optional, default True
            whether to sample with replacement

        Returns
        -------
        int
            a randomly selected stratum index

def _sample_stratum(self, pmf=None, replace=True):
        """Sample a stratum

        Parameters
        ----------
        pmf : array-like, shape=(n_strata,), optional, default None
            probability distribution to use when sampling from the strata. If
            not given, use the stratum weights.

        replace : bool, optional, default True
            whether to sample with replacement

        Returns
        -------
        int
            a randomly selected stratum index
        """
        if pmf is None:
            # Use weights
            pmf = self.weights_

        if not replace:
            # Find strata which have been fully sampled (i.e. are now empty)
            empty = (self._n_sampled >= self.sizes_)
            if np.any(empty):
                pmf = copy.copy(pmf)
                pmf[empty] = 0
                if np.sum(pmf) == 0:
                    raise(RuntimeError)
                pmf /= np.sum(pmf)

        return np.random.choice(self.indices_, p = pmf)