scuq.cucomponents

scuq.cucomponents.complex_to_matrix(value)[source]

This function transforms a complex value into a 2x2 NumPy array.

Parameters:

value – The complex value.

Returns:

A 2x2 numpy.ndarray containing the value.

class scuq.cucomponents.CUncertainComponent[source]

Bases: object

This is the abstract super class of all complex valued uncertain components. Despite defining the interface for complex valued uncertain components, it also provides a set of factory methods that act as an interface for numpy.

depends_on()[source]

This abstact method should return the set of CUncertainInput instances, on which this instance depends on.

Returns:

A list of CUncertainInputs this instance depends on.

get_value()[source]

This abstract method should return the complex value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

This abstact method should return the partial derivate of this component with respect to the input x.

Parameters:

x – An uncertain input.

Returns:

The uncertainty of this component with respect to the input.

get_a_value()[source]

This method returns the value of this component as a 2x2 array.

Returns:

The complex value of this component as a numpy.ndarray.

exp()[source]

Get the exponential of this instance. Let this instance be x then this method returns e^x.

Returns:

The exponential value of this instance.

log()[source]

Get the natural logarithm of this instance. Let this instance be x then this method returns ln(x).

Returns:

The natural logarithm of this instance.

log10()[source]

Get the decadic logarithm of this instance. Let this instance be x then this method returns log_{10}(x).

Returns:

The decadic logarithm of this instance.

log2()[source]

Get the binary logarithm of this instance. Let this instance be x then this method returns log_{2}(x).

Returns:

The binary logarithm of this instance.

sqrt()[source]

Get the square-root of this instance. Let this instance be x then this method returns sqrt{x}.

Returns:

The square-root of this instance.

square()[source]

Get the square of this instance. Let this instance be x then this method returns x cdot x.

Returns:

The square of this instance.

sin()[source]

Get the sine of this instance. Let this instance be x then this method returns sin(x).

Returns:

The sine of this instance.

cos()[source]

Get the cosine of this instance. Let this instance be x then this method returns cos(x).

Returns:

The cosine of this instance.

tan()[source]

Get the tangent of this instance. Let this instance be x then this method returns tan(x).

Returns:

The tangent of this instance.

arcsin()[source]

Get the inverse sine of this instance. Let this instance be x then this method returns sin^{-1}(x).

Returns:

The inverse sine of this instance.

arccos()[source]

Get the inverse cosine of this instance. Let this instance be x then this method returns cos^{-1}(x).

Returns:

The inverse cosine of this instance.

arctan()[source]

Get the inverse tangent of this instance. Let this instance be x then this method returns tan^{-1}(x).

Returns:

The inverse tangent of this instance.

arctan2(y)[source]

Get the two-argument inverse tangent of this instance. Let this instance be x then this method returns tan^{-1}(x).

Parameters:

y – Another component of uncertainty.

Returns:

The two-argument inverse tangent of this instance.

sinh()[source]

Get the hyperbolic sine of this instance. Let this instance be x then this method returns sinh(x).

Returns:

The hyperbolic sine of this instance.

cosh()[source]

Get the hyperbolic cosine of this instance. Let this instance be x then this method returns cosh(x).

Returns:

The hyperbolic cosine of this instance.

tanh()[source]

Get the hyperbolic tangent of this instance. Let this instance be x then this method returns tanh(x).

Returns:

The hyperbolic cosine of this instance.

arcsinh()[source]

Get the inverse hyperbolic sine of this instance. Let this instance be x then this method returns sinh^{-1}(x).

Returns:

The inverse hyperbolic sine of this instance.

arccosh()[source]

Get the inverse hyperbolic cosine of this instance. Let this instance be x then this method returns cosh^{-1}(x).

Returns:

The inverse hyperbolic cosine of this instance.

arctanh()[source]

Get the inverse hyperbolic tangent of this instance. Let this instance be x then this method returns tanh^{-1}(x).

Returns:

The inverse hyperbolic tangent of this instance.

hypot(y)[source]

Calculate the hypothenusis of this and another complex-valued argument.

Parameters:

y – another component of uncertainty.

Returns:

sqrt{x^2 + y^2}

__abs__()[source]

Return the absolute value of this instance. Let this instance be mathbf{z} = x + j y then this method returns

Returns:

The absolute value of this instance.

fabs()[source]

Return the absolute value of this instance. Let this instance be mathbf{z} = x + j y then this method returns

Returns:

The absolute value of this instance.

__neg__()[source]

Negate this instance.

Returns:

The negative of this instance.

__invert__()[source]

Get the inverse of this instance. Let this instance be x then this method returns x^{-1}.

Returns:

The inverse of this instance.

conjugate()[source]

Get the conjuagte complex value of this instance.

Returns:

the conjuagte complex value of this instance.

__add__(y)[source]

Add another instance to this instance.

Parameters:

y – Another uncertain value.

Returns:

The sum of this instance and the other instance.

__sub__(y)[source]

Subtract another instance from this instance.

Parameters:

y – Another uncertain value.

Returns:

The difference of this instance and the other instance.

__mul__(y)[source]

Multiply another instance with this instance.

Parameters:

y – Another uncertain value.

Returns:

The product of this instance and the other instance.

__truediv__(y)[source]

Divide this instance by another instance.

Parameters:

y – Another uncertain value.

Returns:

The result of the respective operation.

__pow__(y)[source]

Raise this instance to the power of the argument.

Parameters:

y – Another uncertain value.

Returns:

The result of the respective operation.

__radd__(y)[source]

Add another instance to this instance.

Parameters:

y – Another uncertain value.

Returns:

The sum of this instance and the other instance.

__rsub__(y)[source]

Subtract another instance from this instance.

Parameters:

y – Another uncertain value.

Returns:

The difference of this instance and the other instance.

__rmul__(y)[source]

Multiply another instance with this instance.

Parameters:

y – Another uncertain value.

Returns:

The product of this instance and the other instance.

__rtruediv__(y)[source]

Divide this instance by another instance.

Parameters:

y – Another uncertain value.

Returns:

The result of the respective operation.

__rpow__(y)[source]

Raise this instance to the power of the argument.

Parameters:

y – Another uncertain value.

Returns:

The result of the respective operation.

static value_of(value)[source]

This factory method converts the argument to a complex uncertain value.

Parameters:

value – A numeric value.

Returns:

An instance of CUncertainComponent.

set_context(c)[source]

This assigns a context to the component. This context is only needed for evaluating __str__

Parameters:

c – An instance of Context

get_context()[source]

This returns the assigned context of the component. This context is only needed for evaluating __str__

Returns:

c The Context of the component or None.

__str__()[source]

This method prints the component of uncertainty.

Returns:

A string describing this component

__coerce__(other)[source]

Implementation of coercion rules. See also: Coercion - The page describing the coercion rules.

class scuq.cucomponents.CUncertainInput(value, u_real, u_imag, dof='inf')[source]

Bases: CUncertainComponent

This class models a complex-valued input of a function.

__init__(value, u_real, u_imag, dof='inf')[source]

The default constructor.

Parameters:
  • value – The value of this instance.

  • u_real – The uncertainty of the real part.

  • u_imag – The uncertainty of the imaginary part.

  • dof – The degrees of freedom of the input.

uncertain. Instead encapsulate an uncertain value inside a quantity.

depends_on()[source]

Returns a list that contains this instance only.

Returns:

A list.

get_value()[source]

Get the value of this input.

Returns:

The value of this input

get_a_value()[source]

Get the value as array.

Returns:

The value of this input as array.

get_uncertainty(x)[source]

If x == self get the uncertainty of the current node, otherwise return a 2x2 array of zeros.

Parameters:

x – Another instance of CUncertainInput

Returns:

The uncertainty of this instance with respect to the argument.

get_dof()[source]

Get the degrees of freedom assigned to this input.

Returns:

The degrees of freedom assigned to this input.

__setstate__(state)[source]

This method provides an interface for deserializing objects using pickle.

Parameters:

state – The state to be restored.

__getstate__()[source]

This method provides an interface for serializing objects using pickle.

Returns:

The state of this component.

class scuq.cucomponents.CUnaryOperation(sibling)[source]

Bases: CUncertainComponent

This abstract class models an unary operation.

__init__(sibling)[source]

The default constructor.

Parameters:

sibling – The sibling of this operation.

get_sibling()[source]

Get the sibling of this operation.

Returns:

The sibling

depends_on()[source]

Get the instances of CUncertainInput that this instance depends on.

Returns:

A list containing the instances of CUncertainInput that this instance depends on.

class scuq.cucomponents.CBinaryOperation(left, right)[source]

Bases: CUncertainComponent

This abstract class models a binary operation.

__init__(left, right)[source]

The default constructor.

Parameters:
  • left – The left sibling sibling of this operation.

  • right – The right sibling sibling of this operation.

get_left()[source]

Get the left sibling of this operation.

Returns:

The sibling

get_right()[source]

Get the right sibling of this operation.

Returns:

The sibling

depends_on()[source]

Get the instances of CUncertainInput that this instance depends on.

Returns:

A list containing the instances of CUncertainInput that this instance depends on.

class scuq.cucomponents.Exp(sibling)[source]

Bases: CUnaryOperation

This class models the exponential function e^x. x denotes the sibling of this instance.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Log(sibling, base=2.718281828459045)[source]

Bases: CUnaryOperation

This class models logarithms having a real base. However, the base cannot be uncertain.

__init__(sibling, base=2.718281828459045)[source]

The default constructor.

Parameters:
  • sibling – The sibling of this instance.

  • base – The base of the logarithm (must be a real number).

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Returns:

The partial derivate.

class scuq.cucomponents.Sqrt(sibling)[source]

Bases: CUnaryOperation

This class models taking the square root of an uncertain component.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Sin(sibling)[source]

Bases: CUnaryOperation

This class models the sine function.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Cos(sibling)[source]

Bases: CUnaryOperation

This class models the cosine function.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Tan(sibling)[source]

Bases: CUnaryOperation

This class models the tangent function.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.ArcSin(sibling)[source]

Bases: CUnaryOperation

This class models the inverse sine function.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.ArcCos(sibling)[source]

Bases: CUnaryOperation

This class models the inverse cosine function.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.ArcTan(sibling)[source]

Bases: CUnaryOperation

This class models the inverse tangent function.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Sinh(sibling)[source]

Bases: CUnaryOperation

This class models the hyperbolic sine function.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Cosh(sibling)[source]

Bases: CUnaryOperation

This class models the hyperbolic cosine function.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Tanh(sibling)[source]

Bases: CUnaryOperation

This class models the hyperbolic tangent function.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.ArcSinh(sibling)[source]

Bases: CUnaryOperation

This class models the inverse hyperbolic sine function.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.ArcCosh(sibling)[source]

Bases: CUnaryOperation

This class models the inverse hyperbolic cosine function.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.ArcTanh(sibling)[source]

Bases: CUnaryOperation

This class models the inverse hyperbolic tangent function.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Abs(sibling)[source]

Bases: CUnaryOperation

This class models taking the absolute value of a complex function.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Conjugate(sibling)[source]

Bases: CUnaryOperation

This class models taking the negative of a complex value.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Neg(sibling)[source]

Bases: CUnaryOperation

This class models taking the negative of a complex value.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Inv(sibling)[source]

Bases: CUnaryOperation

This class models inverting complex values. Let an instance of this class model the complex value x then this class models frac{1}{x}.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Add(left, right)[source]

Bases: CBinaryOperation

This class models adding two complex values.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Sub(left, right)[source]

Bases: CBinaryOperation

This class models taking the difference of two complex values.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Mul(left, right)[source]

Bases: CBinaryOperation

This class models multiplying two complex values.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Div(left, right)[source]

Bases: CBinaryOperation

This class models dividing two complex values.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Pow(left, right)[source]

Bases: CBinaryOperation

This class models complex powers.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.ArcTan2(left, right)[source]

Bases: CBinaryOperation

This class models two-argument inverse tangent.

get_value()[source]

Get the value of this component.

Returns:

The value of this component.

get_uncertainty(x)[source]

Get the partial derivate of this component with respect to the given argument.

Parameters:

x – The argument of the partial derivation.

Returns:

The partial derivate.

class scuq.cucomponents.Context[source]

Bases: object

This class provides a context for complex-valued uncertainty evaluations. It manages the correlation coefficients and is able to evaluate the effective degrees of freedom.

__init__()[source]

The default constructor. It initializes the dictionary of correlation matrices.

gaussian(val, u_r, u_i, dof='inf', matrix=None)[source]

This is a factory method for generating uncertain inputs that have a Gaussian distribution (i.e. bivariate Normal Distribution).

Parameters:
  • val – The complex value of the input.

  • u_r – The uncertainty of the real part.

  • u_i – The uncertainty of the imaginary part.

  • dof – The degrees of freedom of the variable.

  • matrix – Optional 2x2 array-like correlation coefficients.

constant(val)[source]

This is a factory method for generating constans for uncertainty evaluations.

set_correlation(c1, c2, matrix)[source]

This method sets the correlation coefficients of two input arguments.

Parameters:
  • c1 – The first CUncertainInput

  • c2 – The second CUncertainInput

  • matrix – 2x2 array-like correlation coefficients.

get_correlation(c1, c2)[source]

Get the correlation of two input arguments.

Parameters:
  • c1 – The first CUncertainInput

  • c2 – The second CUncertainInput

Returns:

The correlation coefficients as a 2x2 numpy.ndarray.

uncertainty(c)[source]

Get the combined standard uncertainty of a complex-valued component of uncertainty.

Parameters:

c – The component of uncertainty.

Returns:

A 2x2 numpy.ndarray expressing the combined standard uncertainty. If the input has unit [u], the covariance entries have [u^2].

dof(c)[source]

Calculate the effective degrees of freedom of the argument.

Parameters:

c – The component of uncertainty.

Returns:

The number of effective degress of freedom. an infinite DOF. In this case this method returns arithmetic.INFINITY.