Skip to content

A small project for propagating uncertainties faster.

License

Notifications You must be signed in to change notification settings

lmarchetti02/errors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Errors

A data-analysis-oriented library for propagating errors easily.

Description

This library allows to propagate errors on lab measures easily. The user just needs to:

  1. specify the function relating the physical quantities together: $G \equiv G(x_1,x_2,...,x_n)$;
  2. 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}$$
  3. 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} $$

Installation

Follow the steps below to install Plotter (Unix-like systems):

  1. Clone the repository to a directory in your system.
  2. Open the terminal and navigate to said folder.
  3. Run the command
    python3 -m install
  4. A dist directory will be created, containing a .whl file.
  5. To install the package run
    pip3 install /path/to/whl/file
  6. 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.

Usage

The library has two modes.

  1. For products, quotients and sums of physical quantities, highly optimized algorithms can be used. Therefore, the user should use directly the products(), quotients() and sums() functions.
  2. For more complicated functions, a less optimized-but equally fast-algorithm can be used. I these cases, the user should use the functions() function.

Example

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])

License

See the LICENCE file for licence rights and limitations.

About

A small project for propagating uncertainties faster.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages