@classmethod
    def _expected_values(cls, cont):
        """Calculates expected values for a contingency table."""
        n_all = sum(cont)
        bits = [1 << i for i in range(cls._n)]

        # For each contingency table cell
        for i in range(len(cont)):
            # Yield the expected value
            yield (_product(sum(cont[x] for x in range(2 ** cls._n)
                                if (x & j) == (i & j))
                            for j in bits) /
                   (n_all ** (cls._n - 1)))
dataset/ETHPy150Open nltk/nltk/nltk/metrics/association.py/NgramAssocMeasures._expected_values/original