Skip to content

Commit

Permalink
perf: chi2 max residual using numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrugman committed May 20, 2022
1 parent ff72d6e commit 8596387
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions popmon/analysis/comparison/hist_comparer.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,17 @@ def hist_compare(row, hist_name1="", hist_name2="", max_res_bound=7.0):
pearson, pvalue = pearsonr(*entries_list)

chi2, chi2_norm, zscore, pvalue, res = uu_chi2(*entries_list)
abs_residual = np.abs(res)
chi2_max_residual = np.max(abs_residual)
chi2_spike_count = np.sum(abs_residual[abs_residual > max_res_bound])

x["pearson"] = pearson
x["chi2"] = chi2
x["chi2_norm"] = chi2_norm
x["chi2_zscore"] = zscore
x["chi2_pvalue"] = pvalue
x["chi2_max_residual"] = max(list(map(abs, res)))
x["chi2_spike_count"] = sum(abs(r) > max_res_bound for r in res)
x["chi2_max_residual"] = chi2_max_residual
x["chi2_spike_count"] = chi2_spike_count
for key, func in Comparisons.get_comparisons().items():
x[key] = func(*entries_list)
return pd.Series(x)
Expand Down

0 comments on commit 8596387

Please sign in to comment.