mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-12-22 03:23:34 +01:00
ZH: figlib: stabilise chisquare calculation
This commit is contained in:
parent
80cc240f23
commit
581b83ac5b
2 changed files with 7 additions and 1 deletions
|
@ -245,6 +245,8 @@ def fitted_histogram_figure(
|
||||||
chisq_strs = []
|
chisq_strs = []
|
||||||
if calc_chisq and cdf:
|
if calc_chisq and cdf:
|
||||||
ct = np.diff(cdf(bins, *fit_params))*np.sum(counts)
|
ct = np.diff(cdf(bins, *fit_params))*np.sum(counts)
|
||||||
|
if True: # stabilise the chisquare derivation
|
||||||
|
ct *= np.sum(counts)/np.sum(ct)
|
||||||
c2t = stats.chisquare(counts, ct, ddof=len(fit_params))
|
c2t = stats.chisquare(counts, ct, ddof=len(fit_params))
|
||||||
chisq_strs = [
|
chisq_strs = [
|
||||||
f"$\\chi^2$/dof = {c2t[0]: .2g}/{len(fit_params)}"
|
f"$\\chi^2$/dof = {c2t[0]: .2g}/{len(fit_params)}"
|
||||||
|
|
|
@ -111,7 +111,11 @@ def my_correlation(in1, template, lags=None):
|
||||||
return corrs, (in1, template, lags)
|
return corrs, (in1, template, lags)
|
||||||
|
|
||||||
def trace_upsampler(trace, template_t, trace_t):
|
def trace_upsampler(trace, template_t, trace_t):
|
||||||
template_dt = template_t[1] - template_t[0]
|
if not hasattr(template_t, '__len__'):
|
||||||
|
template_dt = template_t
|
||||||
|
else:
|
||||||
|
template_dt = template_t[1] - template_t[0]
|
||||||
|
|
||||||
trace_dt = trace_t[1] - trace_t[0]
|
trace_dt = trace_t[1] - trace_t[0]
|
||||||
|
|
||||||
upsample_factor = trace_dt/template_dt
|
upsample_factor = trace_dt/template_dt
|
||||||
|
|
Loading…
Reference in a new issue