This tutorial will talk about how to treat data with errors.
NOTE FOR CONTRIBUTORS: Always clear all output before committing (Cell
> All Output
> Clear
)!
# Magic
%matplotlib inline
# Reload modules whenever they change
%load_ext autoreload
%autoreload 2
# Make clusterking package available even without installation
import sys
sys.path = ["../../"] + sys.path
import clusterking as ck
import numpy as np
Loading the data created in Tutorial 1, this time as a DataWithErrors
object (which has additional methods to add errors)
dwe = ck.DataWithErrors("output/tutorial_basics.sql")
dwe.add_err_poisson(500)
dwe.add_err_...
(or dwe.add_rel_err_...
) cells more than once, or the error gets added multiple times!
Add a relative error of 10% to all the bin contents (without any correlation between the bins):
dwe.add_rel_err_uncorr(0.1)
Similar, if you want to give individual errors per bin (e.g. an additional 10% error to the first bin):
dwe.add_rel_err_uncorr([0.1, 0, 0, 0, 0, 0, 0, 0, 0])
Similarly you can also add absolute errors, e.g.:
dwe.add_err_uncorr(0.001)
To add normalization errors, which are maximally correlated across bin, there is the shortcut:
dwe.add_rel_err_maxcorr(0.05) # Add a 5% normalization error
#corr = np.ones(9)
#add_err(relative=True/False, corr="max", None, cov=None, err=None, )
You can also add an error together with a custom correlation matrix: For a trivial example, the following errors will also be uncorrelated:
corr = np.eye(9) # Unit matrix
dwe.add_rel_err_corr(0.01, corr)
dwe.plot_dist_err();
dwe.err()
dwe.corr()
dwe.cov()
dwe.data(decorrelate=True)