This tutorial will talk about how to treat data with errors.
NOTE FOR CONTRIBUTORS: Always clear all output before commiting (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
Loading the data created in Tutorial 1, this time as a DataWithErrors
object (which has additional methods to add errors)
dwe = ck.DataWithErrors("output/cluster/", "tutorial_basics")
dwe.add_err_poisson(200)
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(1)
To add normalization errors, which are maximally correlated accross bin, there is the shortcut:
dwe.add_rel_err_maxcorr(0.5) # Add a 50% 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 follwing errors will also be uncorrelated:
corr = np.eye(9) # Unit matrix
dwe.add_rel_err_corr(0.1, corr)
dwe.err()
dwe.corr()
dwe.cov()
dwe.data(decorrelate=True)