mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-15 12:03:42 +02:00
refactor!: ks_test removed from develop for now.
This commit is contained in:
parent
87c50f54c0
commit
c2ff8c715a
1 changed files with 0 additions and 47 deletions
|
@ -1,4 +1,3 @@
|
||||||
import gc
|
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
import warnings
|
import warnings
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
@ -739,49 +738,3 @@ def error_band(x, func, beta):
|
||||||
err = np.array(err)
|
err = np.array(err)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
|
||||||
def ks_test(obs=None):
|
|
||||||
"""Performs a Kolmogorov–Smirnov test for the Q-values of all fit object.
|
|
||||||
|
|
||||||
If no list is given all Obs in memory are used.
|
|
||||||
|
|
||||||
Disclaimer: The determination of the individual Q-values as well as this function have not been tested yet.
|
|
||||||
"""
|
|
||||||
|
|
||||||
raise Exception('Not yet implemented')
|
|
||||||
|
|
||||||
if obs is None:
|
|
||||||
obs_list = []
|
|
||||||
for obj in gc.get_objects():
|
|
||||||
if isinstance(obj, Obs):
|
|
||||||
obs_list.append(obj)
|
|
||||||
else:
|
|
||||||
obs_list = obs
|
|
||||||
|
|
||||||
# TODO: Rework to apply to Q-values of all fits in memory
|
|
||||||
Qs = []
|
|
||||||
for obs_i in obs_list:
|
|
||||||
for ens in obs_i.e_names:
|
|
||||||
if obs_i.e_Q[ens] is not None:
|
|
||||||
Qs.append(obs_i.e_Q[ens])
|
|
||||||
|
|
||||||
bins = len(Qs)
|
|
||||||
x = np.arange(0, 1.001, 0.001)
|
|
||||||
plt.plot(x, x, 'k', zorder=1)
|
|
||||||
plt.xlim(0, 1)
|
|
||||||
plt.ylim(0, 1)
|
|
||||||
plt.xlabel('Q value')
|
|
||||||
plt.ylabel('Cumulative probability')
|
|
||||||
plt.title(str(bins) + ' Q values')
|
|
||||||
|
|
||||||
n = np.arange(1, bins + 1) / np.float64(bins)
|
|
||||||
Xs = np.sort(Qs)
|
|
||||||
plt.step(Xs, n)
|
|
||||||
diffs = n - Xs
|
|
||||||
loc_max_diff = np.argmax(np.abs(diffs))
|
|
||||||
loc = Xs[loc_max_diff]
|
|
||||||
plt.annotate(s='', xy=(loc, loc), xytext=(loc, loc + diffs[loc_max_diff]), arrowprops=dict(arrowstyle='<->', shrinkA=0, shrinkB=0))
|
|
||||||
plt.draw()
|
|
||||||
|
|
||||||
print(scipy.stats.kstest(Qs, 'uniform'))
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue