pyblock.error¶
Simple error propogation.
Note
We only implement the functions as we need them…
-
pyblock.error.ratio(stats_A, stats_B, cov_AB, data_len)¶ Calculate the mean and standard error of \(f(A,B) = A/B\).
- stats_A :
pandas.Seriesorpandas.DataFrame - Statistics (containing at least the ‘mean’ and ‘standard error’ fields) for
variable \(A\). The rows contain different values of these statistics
(e.g. from a reblocking analysis) if
pandas.DataFrameare passed. - stats_B :
pandas.Seriesorpandas.DataFrame - Similarly for variable \(B\).
- cov_AB : float or
pandas.Series - Covariance between variables \(A\) and \(B\). If
stats_Aandstats_Barepandas.DataFrame, then this must be apandas.Series, with the same index asstats_Aandstats_B. - data_len : int or
pandas.Series - Number of data points (‘observations’) used to obtain the statistics given
in
stats_Aandstats_B. Ifstats_Aandstats_Barepandas.DataFrame, then this must be apandas.Series, with the same index asstats_Aandstats_B.
- stats :
pandas.Seriesorpandas.DataFrame - Mean and standard error (and, if possible/relevant, optimal reblock
iteration) for \(f(A,B)\). If
stats_A,stats_Barepandas.DataFrame, this is apandas.DataFramewith the same index, otherwise apandas.Seriesis returned.
- stats_A :
-
pyblock.error.product(stats_A, stats_B, cov_AB, data_len)¶ Calculate the mean and standard error of \(f(A,B) = A \times B\).
See
ratio().See
ratio().
-
pyblock.error.subtraction(stats_A, stats_B, cov_AB, data_len)¶ Calculate the mean and standard error of \(f(A,B) = A - B\).
See
ratio().See
ratio().
-
pyblock.error.addition(stats_A, stats_B, cov_AB, data_len)¶ Calculate the mean and standard error of \(f(A,B) = A \plus B\).
See
ratio().See
ratio().
-
pyblock.error.pretty_fmt_err(val, err)¶ Pretty formatting of a value and associated error.
- val : number
- a (noisy) value.
- err: number
- error associated with the value.
- val_str : str
- Value to the number of significant digits known, with the error in the last digit in brackets.
>>> pretty_fmt_err(1.2345, 0.01) '1.23(1)' >>> pretty_fmt_err(12331, 40) '12330(40)'
Rounding is handled with Python’s round function, which handles rounding numbers at the midpoint in a range (eg 5 if round to the nearest 10) in a slightly odd way. As we’re normally dealing with noisy data and rounding to remove more than just one significant figure, this is unlikely to impact us.