Package ComboCode :: Package cc :: Package ivs :: Package sigproc :: Package lmfit :: Package uncertainties :: Package unumpy
[hide private]
[frames] | no frames]

Package unumpy

source code

Utilities for NumPy arrays and matrices that contain numbers with
uncertainties.

This package contains:

1) utilities that help with the creation and manipulation of NumPy
arrays and matrices of numbers with uncertainties;

2) generalizations of multiple NumPy functions so that they also work
with arrays that contain numbers with uncertainties.

- Arrays of numbers with uncertainties can be built as follows:

  arr = unumpy.uarray(([1, 2], [0.01, 0.002]))  # (values, uncertainties)

NumPy arrays of numbers with uncertainties can also be built directly
through NumPy, thanks to NumPy's support of arrays of arbitrary objects:

  arr = numpy.array([uncertainties.ufloat((1, 0.1)),...])
  
- Matrices of numbers with uncertainties are best created in one of
two ways:

  mat = unumpy.umatrix(([1, 2], [0.01, 0.002]))  # (values, uncertainties)

Matrices can also be built by converting arrays of numbers with
uncertainties, through the unumpy.matrix class:

  mat = unumpy.matrix(arr)

unumpy.matrix objects behave like numpy.matrix objects of numbers with
uncertainties, but with better support for some operations (such as
matrix inversion):

  # The inverse or pseudo-inverse of a unumpy.matrix can be calculated:
  print mat.I  # Would not work with numpy.matrix([[ufloat(...),...]]).I

- Nominal values and uncertainties of arrays can be directly accessed:

  print unumpy.nominal_values(arr)  # [ 1.  2.]
  print unumpy.std_devs(mat)  # [ 0.01   0.002]

- This module defines uncertainty-aware mathematical functions that
generalize those from uncertainties.umath so that they work on NumPy
arrays of numbers with uncertainties instead of just scalars:

  print unumpy.cos(arr)  # Array with the cosine of each element

NumPy's function names are used, and not those of the math module (for
instance, unumpy.arccos is defined, like in NumPy, and is not named
acos like in the standard math module).

The definitions of the mathematical quantities calculated by these
functions are available in the documentation of uncertainties.umath.

- The unumpy.ulinalg module contains more uncertainty-aware functions
for arrays that contain numbers with uncertainties (see the
documentation for this module).

This module requires the NumPy package.

(c) 2009-2013 by Eric O. LEBIGOT (EOL) <eric.lebigot@normalesup.org>.
Please send feature requests, bug reports, or feedback to this address.

This software is released under a dual license.  (1) The BSD license.
(2) Any other license, as long as it is obtained from the original
author.


Author: Eric O. LEBIGOT (EOL) <eric.lebigot@normalesup.org>

Submodules [hide private]

Classes [hide private]
  matrix
Class equivalent to numpy.matrix, but that behaves better when the matrix contains numbers with uncertainties.
Functions [hide private]
 
nominal_values(arr)
Returns the nominal values of the numbers in NumPy array arr.
source code
 
std_devs(arr)
Returns the standard deviations of the numbers in NumPy array arr.
source code
 
uarray((values, std_devs))
Returns a NumPy array of numbers with uncertainties initialized with the given nominal values and standard deviations.
source code
 
umatrix(*args)
Constructs a matrix that contains numbers with uncertainties.
source code
Variables [hide private]
  __all__ = core.__all__
  __package__ = 'ComboCode.cc.ivs.sigproc.lmfit.uncertainties.un...
  arccos = <numpy.lib.function_base.vectorize object at 0x10e669...
  arccosh = <numpy.lib.function_base.vectorize object at 0x10e66...
  arcsin = <numpy.lib.function_base.vectorize object at 0x10e669...
  arctan = <numpy.lib.function_base.vectorize object at 0x10e669...
  arctan2 = <numpy.lib.function_base.vectorize object at 0x10e66...
  arctanh = <numpy.lib.function_base.vectorize object at 0x10e66...
  asinh = <numpy.lib.function_base.vectorize object at 0x10e669d50>
  ceil = <numpy.lib.function_base.vectorize object at 0x10e669e50>
  copysign = <numpy.lib.function_base.vectorize object at 0x10e6...
  cos = <numpy.lib.function_base.vectorize object at 0x10e669ed0>
  cosh = <numpy.lib.function_base.vectorize object at 0x10e669f10>
  degrees = <numpy.lib.function_base.vectorize object at 0x10e66...
  erf = <numpy.lib.function_base.vectorize object at 0x10e669f90>
  erfc = <numpy.lib.function_base.vectorize object at 0x10e669fd0>
  exp = <numpy.lib.function_base.vectorize object at 0x10e67c050>
  expm1 = <numpy.lib.function_base.vectorize object at 0x10e67c090>
  fabs = <numpy.lib.function_base.vectorize object at 0x10e67c0d0>
  floor = <numpy.lib.function_base.vectorize object at 0x10e67c110>
  fmod = <numpy.lib.function_base.vectorize object at 0x10e67c150>
  gamma = <numpy.lib.function_base.vectorize object at 0x10e67c190>
  hypot = <numpy.lib.function_base.vectorize object at 0x10e67c1d0>
  isinf = <numpy.lib.function_base.vectorize object at 0x10e67c210>
  isnan = <numpy.lib.function_base.vectorize object at 0x10e67c250>
  ldexp = <numpy.lib.function_base.vectorize object at 0x10e67c5d0>
  lgamma = <numpy.lib.function_base.vectorize object at 0x10e67c...
  log = <numpy.lib.function_base.vectorize object at 0x10e67c2d0>
  log10 = <numpy.lib.function_base.vectorize object at 0x10e67c310>
  log1p = <numpy.lib.function_base.vectorize object at 0x10e67c350>
  modf = <numpy.lib.function_base.vectorize object at 0x10e67c590>
  pow = <numpy.lib.function_base.vectorize object at 0x10e67c390>
  radians = <numpy.lib.function_base.vectorize object at 0x10e67...
  sin = <numpy.lib.function_base.vectorize object at 0x10e67c410>
  sinh = <numpy.lib.function_base.vectorize object at 0x10e67c450>
  sqrt = <numpy.lib.function_base.vectorize object at 0x10e67c490>
  tan = <numpy.lib.function_base.vectorize object at 0x10e67c4d0>
  tanh = <numpy.lib.function_base.vectorize object at 0x10e67c510>
  trunc = <numpy.lib.function_base.vectorize object at 0x10e67c550>
Function Details [hide private]

nominal_values(arr)

source code 

Returns the nominal values of the numbers in NumPy array arr.

Elements that are not uncertainties.AffineScalarFunc are passed through untouched (because a numpy.array can contain numbers with uncertainties and pure floats simultaneously).

If arr is of type unumpy.matrix, the returned array is a numpy.matrix, because the resulting matrix does not contain numbers with uncertainties.

std_devs(arr)

source code 

Returns the standard deviations of the numbers in NumPy array arr.

Elements that are not uncertainties.AffineScalarFunc are given a zero uncertainty ((because a numpy.array can contain numbers with uncertainties and pure floats simultaneously)..

If arr is of type unumpy.matrix, the returned array is a numpy.matrix, because the resulting matrix does not contain numbers with uncertainties.

uarray((values, std_devs))

source code 

Returns a NumPy array of numbers with uncertainties initialized with the given nominal values and standard deviations.

values, std_devs -- valid arguments for numpy.array, with identical shapes (list of numbers, list of lists, numpy.ndarray, etc.).

umatrix(*args)

source code 

Constructs a matrix that contains numbers with uncertainties.

The input data is the same as for uarray(...): a tuple with the nominal values, and the standard deviations.

The returned matrix can be inverted, thanks to the fact that it is a unumpy.matrix object instead of a numpy.matrix one.


Variables Details [hide private]

__package__

Value:
'ComboCode.cc.ivs.sigproc.lmfit.uncertainties.unumpy'

arccos

Value:
<numpy.lib.function_base.vectorize object at 0x10e669c50>

arccosh

Value:
<numpy.lib.function_base.vectorize object at 0x10e669cd0>

arcsin

Value:
<numpy.lib.function_base.vectorize object at 0x10e669d10>

arctan

Value:
<numpy.lib.function_base.vectorize object at 0x10e669d90>

arctan2

Value:
<numpy.lib.function_base.vectorize object at 0x10e669dd0>

arctanh

Value:
<numpy.lib.function_base.vectorize object at 0x10e669e10>

copysign

Value:
<numpy.lib.function_base.vectorize object at 0x10e669e90>

degrees

Value:
<numpy.lib.function_base.vectorize object at 0x10e669f50>

lgamma

Value:
<numpy.lib.function_base.vectorize object at 0x10e67c290>

radians

Value:
<numpy.lib.function_base.vectorize object at 0x10e67c3d0>