Skip to content

Commit

Permalink
Merge pull request #390 from Crunch-io/fix-pw-sig-means-186401453
Browse files Browse the repository at this point in the history
fix bases calculation for pw sig means
  • Loading branch information
ernestoarbitrio authored Nov 3, 2023
2 parents 1d2759c + 1884436 commit de5e37b
Show file tree
Hide file tree
Showing 4 changed files with 2,562 additions and 17 deletions.
6 changes: 2 additions & 4 deletions src/cr/cube/matrix/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1389,13 +1389,11 @@ def t_stats(self):

means = self._cube_measures.cube_means.means
variance = np.power(self._cube_measures.cube_stddev.stddev, 2)
col_bases = self._cube_measures.unweighted_cube_counts.column_bases
col_bases = self._cube_measures.unweighted_cube_counts.counts
idx = self._selected_column_idx

ref_means = np.broadcast_to(means[:, [idx]], means.shape)
ref_variance = np.broadcast_to(variance[:, [idx]], variance.shape)
ref_col_bases = np.broadcast_to(col_bases[:, [idx]], col_bases.shape)

with np.errstate(divide="ignore", invalid="ignore"):
return (means - ref_means) / np.sqrt(
(variance / col_bases) + (ref_variance / ref_col_bases)
Expand Down Expand Up @@ -1431,7 +1429,7 @@ def _df(self):
df = ( (s1/N1) + (s2/N2) )^2 / ( (s1/N1)^2/(N1-1) + (s2/N2)^2/(N2-1) )
"""
variance = np.power(self._cube_measures.cube_stddev.stddev, 2)
col_bases = self._cube_measures.unweighted_cube_counts.column_bases
col_bases = self._cube_measures.unweighted_cube_counts.counts
idx = self._selected_column_idx

ref_variance = np.broadcast_to(variance[:, [idx]], variance.shape)
Expand Down
Loading

0 comments on commit de5e37b

Please sign in to comment.