pyuncertainnumber.propagation.taylor_expansion ============================================== .. py:module:: pyuncertainnumber.propagation.taylor_expansion Functions --------- .. autoapisummary:: pyuncertainnumber.propagation.taylor_expansion.taylor_expansion_method pyuncertainnumber.propagation.taylor_expansion.taylor_expansion_method_scalar pyuncertainnumber.propagation.taylor_expansion.taylor_expansion_method_vector Module Contents --------------- .. py:function:: taylor_expansion_method(func, mean, *, var=None, cov=None) -> tuple Performs uncertainty propagation using the Taylor expansion method. :param func: function to propagate uncertainty through. Expecting a iterable-signature function. :param mean: mean of the input random variable (scalar or vector) :type mean: Jax array :param var: variance of the input random variable (scalar only) :type var: Jax array :param cov: covariance matrix of the input random vector (vector only) :type cov: Jax array :returns: mean of the output random variable through the function var_f: variance of the output random variable through the function :rtype: mu_f .. note:: Currently it only supports scalar-output functions. Also, for multivariate function, the calling signature is assumed to be func(x) where x is a 1D array, i.e. func: R^n -> R, the vec style. For best compatibility to work with derivatives, the `func` is better written in jax.numpy. .. rubric:: Example >>> import jax.numpy as jnp >>> from pyuncertainnumber import taylor_expansion_method >>> MEAN= jnp.array([3., 2.5]) >>> COV = jnp.array([[4, 0.3], [0.3, 0.25]]) >>> def bar(x): return x[0]**2 + x[1] + 3 >>> mu_, var_ = taylor_expansion_method(func=bar, mean=MEAN, cov=COV) .. py:function:: taylor_expansion_method_scalar(func, mean, var) -> tuple For scalar random variable only .. py:function:: taylor_expansion_method_vector(func, mean, cov) -> tuple For random vector only