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.Series or pandas.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.DataFrame are passed.
stats_B : pandas.Series or pandas.DataFrame
Similarly for variable \(B\).
cov_AB : float or pandas.Series
Covariance between variables \(A\) and \(B\). If stats_A and stats_B are pandas.DataFrame, then this must be a pandas.Series, with the same index as stats_A and stats_B.
data_len : int or pandas.Series
Number of data points (‘observations’) used to obtain the statistics given in stats_A and stats_B. If stats_A and stats_B are pandas.DataFrame, then this must be a pandas.Series, with the same index as stats_A and stats_B.
stats : pandas.Series or pandas.DataFrame
Mean and standard error (and, if possible/relevant, optimal reblock iteration) for \(f(A,B)\). If stats_A, stats_B are pandas.DataFrame, this is a pandas.DataFrame with the same index, otherwise a pandas.Series is returned.
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.