Skip to content
Snippets Groups Projects
Commit 326fa661 authored by Danilo Ferreira de Lima's avatar Danilo Ferreira de Lima
Browse files

Using Z-value for the consistency check.

parent 27cbdaad
No related branches found
No related tags found
1 merge request!7Improve fit
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
Estimate high-resolution photon spectrometer data from low-resolution non-invasive measurements. Estimate high-resolution photon spectrometer data from low-resolution non-invasive measurements.
""" """
VERSION = "0.0.4" VERSION = "0.0.5"
...@@ -772,11 +772,12 @@ class Model(TransformerMixin, BaseEstimator): ...@@ -772,11 +772,12 @@ class Model(TransformerMixin, BaseEstimator):
for ch in channels} for ch in channels}
chi2 = {ch: np.sum(deviation[ch]**2, axis=1, keepdims=True) chi2 = {ch: np.sum(deviation[ch]**2, axis=1, keepdims=True)
for ch in channels} for ch in channels}
cutoff = {ch: scipy.stats.chi2.ppf(0.05, df=deviation[ch].shape[1] - 1) chi2_mu = {ch: scipy.stats.chi2.mean(ndof[ch])
for ch in channels}
chi2_sigma = {ch: scipy.stats.chi2.std(ndof[ch])
for ch in channels}
return {ch: (chi2[ch] - chi2_mu[ch])/chi2_sigma[ch]
for ch in channels} for ch in channels}
ts = {ch: (chi2[ch] - cutoff[ch])/ndof[ch]
for ch in channels}
return ts
# checking channel relevance # checking channel relevance
#pca_model = self.x_model['pca'] #pca_model = self.x_model['pca']
...@@ -812,9 +813,9 @@ class Model(TransformerMixin, BaseEstimator): ...@@ -812,9 +813,9 @@ class Model(TransformerMixin, BaseEstimator):
deviation = (low_pca - self.x_pca_mean)/self.x_pca_std deviation = (low_pca - self.x_pca_mean)/self.x_pca_std
ndof = float(deviation.shape[1] - 1) ndof = float(deviation.shape[1] - 1)
chi2 = np.sum(deviation**2, axis=1, keepdims=True) chi2 = np.sum(deviation**2, axis=1, keepdims=True)
cutoff = scipy.stats.chi2.ppf(0.05, df=deviation.shape[1] - 1) chi2_mu = scipy.stats.chi2.mean(ndof)
ts = (chi2 - cutoff)/ndof chi2_sigma = scipy.stats.chi2.std(ndof)
return ts return (chi2 - chi2_mu)/chi2_sigma
#low_pca_rec = pca_model.inverse_transform(low_pca) #low_pca_rec = pca_model.inverse_transform(low_pca)
#low_pca_unc = self.x_model['unc'].uncertainty() #low_pca_unc = self.x_model['unc'].uncertainty()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment