Zbigniew Sroczynski

# NAME

Math::ErrorPropagation - Computes the error of a function of statistical data

# SYNOPSIS

use ErrorPropagation;

\$x1 = Math::ErrorPropagation->datum(value=>1.2, var=>0.1); \$x2 = Math::ErrorPropagation->datum(value=>2.3, var=>0.12); \$x3 = Math::ErrorPropagation->datum(value=>3.5); \$x3->sd(0.23);

\$f = sin(0.5*\$x1)/(\$x2**3)+log(\$x3); printf ("f = %f +/- %f", \$f->central_value(), \$f-sd());

# DESCRIPTION

A function f({X_i}) of a set of n independent stochastic variables {X_i}={X_0, X_1, ..., X_(n-1)} with means {x_i}={x_0, x_1, ..., x_(n-1)} and corresponding variances {var_i}={var_0, var_1, ..., var_(n-1)}, has mean f({x_i}) and a variance var_f which is the sum of the squared partial derivatives multiplied by the variances

var_f = (df/dx_i)**2 var_i

This package allows the propagation of errors on the variables through various simple mathematical operations to automatically compute the error of the function. Use it to define data each with a central (mean) value and either the variance or standard deviation (square root of the variance), then apply perls mathematical operators to them to calculate your function f. These operators are overloaded so that f automatically has the correct variance.

## METHODS

\$x = Math::ErrorPropagation->datum(value=>1.2, var=>0.1);

initialise a datum with mean 1.2 and variance 0.1

\$x = Math::ErrorPropagation->datum();

initialise an empty datum

\$x->central_value(2.3);

assign a central value

\$x->variance(0.25);

assign a variance

\$x->sd(0.5);

assign a standard deviation

\$m = \$x->central_value(2.3);

read the central value

\$v = \$x->variance(0.25);

read the variance

\$s = \$x->sd(0.5);

read the standard deviation

\$y = copy \$x;

copy a datum

\$z = 1.2+\$y;
\$z = \$y+\$x;
\$z = \$y+2.3;
\$z += \$x;

add data

\$z++;

increment datum

\$z = \$y-\$x;
\$z = \$y-2.3;
\$z = 1.2-\$y;
\$z -= \$x;

subtract data

\$z--;

decrement datum

\$z = \$y*\$x;
\$z = \$y*2.3;
\$z = 1.2*\$y;
\$z *= \$x;

multiply data

\$z = \$y/\$x;
\$z = \$y/2.3;
\$z = 1.2/\$y;
\$z /= \$x;

divide data

\$z = \$y**\$x;
\$z = \$y**2.3;
\$z = 1.2**\$y;

powers

\$z = exp(\$x);
\$z = sin(\$x);
\$z = cos(\$x);
\$z = log(\$x);
\$z = sqrt(\$x);

some mathematical functions

# THINGS TO DO

Find bugs/flakiness.

Add more mathematical functions, particularly some of those in Math::Trig

# AUTHOR

Z. Sroczynski <zs@theorie.physik.uni-wuppertal.de>

perl.