def sample_from_distribution(self, distribution, k, proportions=False):
dist = self._get_column(distribution)<EOL>total = sum(dist)<EOL>assert total > <NUM_LIT:0> and np.all(dist >= <NUM_LIT:0>), '<STR_LIT>'<EOL>dist = dist/sum(dist)<EOL>sample = np.random.multinomial(k, dist)<EOL>if proportions:<EOL><INDENT>sample = sample / sum(sample)<EOL><DEDENT>label = self._unused_label(self._as_label(distribution) + '<STR_LIT>')<EOL>return self.with_column(label, sample)<EOL>
Return a new table with the same number of rows and a new column.
        The values in the distribution column are define a multinomial.
        They are replaced by sample counts/proportions in the output.

        >>> sizes = Table(['size', 'count']).with_rows([
        ...     ['small', 50],
        ...     ['medium', 100],
        ...     ['big', 50],
        ... ])
        >>> sizes.sample_from_distribution('count', 1000) # doctest: +SKIP
        size   | count | count sample
        small  | 50    | 239
        medium | 100   | 496
        big    | 50    | 265
        >>> sizes.sample_from_distribution('count', 1000, True) # doctest: +SKIP
        size   | count | count sample
        small  | 50    | 0.24
        medium | 100   | 0.51
        big    | 50    | 0.25