A data-analysis-oriented library for propagating errors easily.
This library allows to propagate errors on lab measures easily. The user just needs to:
- specify the function relating the physical quantities together:
$G \equiv G(x_1,x_2,...,x_n)$ ; - input the arrays with the measures of each quantity, and their errors: $$\begin{split} &\bar{\textbf{x}}1=(\bar{x}{1,1},...,\bar{x}_{1,k}), \ \bar{\textbf{x}}2,...\ &\boldsymbol{\sigma}1=(\sigma{1,1},..., \ \sigma{1,k}), \boldsymbol{\sigma}_2,... \end{split}$$
- get back the array with the propagated errors, where each element is given by the following: $$ \sigma_{G} = \sqrt{\sum_{j=1}^n\left( \frac{\partial G}{\partial x_j}(\bar{\textbf{x}}) \right)^2\sigma_j^2} $$
Follow the steps below to install Plotter (Unix-like systems):
- Clone the repository to a directory in your system.
- Open the terminal and navigate to said folder.
- Run the command
python3 -m install
- A dist directory will be created, containing a .whl file.
- To install the package run
pip3 install /path/to/whl/file
- If the installation was successful, Plotter can be
imported simply by
import errors as e
Note: It is possible that the commands to use are python
and pip
, instead of, respectively, python3
and pip3
.
The library has two modes.
- For products, quotients and sums of physical quantities, highly optimized algorithms can be used. Therefore, the user should use directly the
products()
,quotients()
andsums()
functions. - For more complicated functions, a less optimized-but equally fast-algorithm can be used. I these cases, the user should use the
functions()
function.
The following example shows all the main features of the library.
import numpy as np
import errors as e
size = 1_000_000
# first quantity
x = np.random.binomial(100, 0.3, size)
x_err = np.random.uniform(0.01, 0.03, size)
# second quantity
y = np.random.normal(0, 1, size)
y_err = np.random.uniform(0.1, 0.2, size)
# product
p = x * y
p_err = e.products(x, y, x_err, y_err)
# quotient
q = x / y
q_err = e.quotients(x, y, x_err, y_err)
# sum
s = x + y
s_err = e.sums(x, y, x_err, y_err)
# function
f = x**2 + 2 * y * x
f_err = e.functions(("x", "y"), "x^2 + 2*y*x", [x, y], [x_err, y_err])
See the LICENCE file for licence rights and limitations.