def emp_dist(values): """ Takes an array of values and returns an empirical distribution Parameters ---------- values : array Array of values that will be grouped by the distribution Returns ------- Table A distribution Examples -------- >>> x = make_array(1, 1, 1, 1, 1, 2, 3, 3, 3, 4) >>> emp_dist(x) Value | Proportion 1 | 0.5 2 | 0.1 3 | 0.3 4 | 0.1 """ total = len(values) position_counts = Table().with_column('position', values).group(0) new_dist = Table().values(position_counts.column(0)) return new_dist.with_column( 'Proportion', position_counts.column(1) / total )
def with_column(self, *args, **kwargs): return self._fix_(Table.with_column(*args, **kwargs))
def with_column(self, label, values): return self._fix_(Table.with_column(self, label, values))