Skip to content

Commit

Permalink
feat: implement MoE
Browse files Browse the repository at this point in the history
  • Loading branch information
slobodan-ilic committed Oct 28, 2020
1 parent c4c5f3b commit dc4327e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/cr/cube/cubepart.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ class _Slice(CubePartition):
dimensions which can be crosstabbed in a slice.
"""

z_alpha = 1.959964

def __init__(self, cube, slice_idx, transforms, population, mask_size):
super(_Slice, self).__init__(cube, transforms)
self._slice_idx = slice_idx
Expand Down Expand Up @@ -291,6 +293,13 @@ def columns_dimension_type(self):
def columns_margin(self):
return np.array([column.margin for column in self._matrix.columns]).T

@lazyproperty
def columns_moe(self):
"""Returns the margin of error (MoE) for cell percentages
`moe = z(0.25) * 100 * std_error`
"""
return self.z_alpha * 100 * self.columns_std_err

@lazyproperty
def columns_std_dev(self):
"""Returns the standard deviation for cell percentages
Expand Down Expand Up @@ -762,6 +771,10 @@ def table_margin(self):
def table_margin_unpruned(self):
return self._matrix.table_margin_unpruned

@lazyproperty
def table_moe(self):
return self.z_alpha * 100 * self.table_std_err

@lazyproperty
def table_name(self):
"""Provides differentiated name for each stacked table of a 3D cube."""
Expand Down

0 comments on commit dc4327e

Please sign in to comment.