punpy.mc.mc_propagation.MCPropagation.propagate_cov_flattened

punpy.mc.mc_propagation.MCPropagation.propagate_cov_flattened#

MCPropagation.propagate_cov_flattened(func, x, cov_x, param_fixed=None, corr_between=None, samples=None, return_corr=True, return_samples=False, repeat_dims=-99, corr_dims=-99, separate_corr_dims=False, fixed_corr_var=False, output_vars=1, PD_corr=True, refyvar=0, pdf_shape='gaussian', pdf_params=None)[source]#

Propagate uncertainties with given covariance matrix through measurement function with n input quantities. Input quantities can be floats, vectors (1d-array) or images (2d-array). The covariance matrix can represent the full covariance matrix between all measurements in all dimensions. Alternatively if there are repeated measurements specified in repeat_dims, the covariance matrix is given for the covariance along the dimension that is not one of the repeat_dims.

Parameters:
  • func (function) – measurement function

  • x (list[array]) – list of input quantities (usually numpy arrays)

  • cov_x (list[array]) – list of covariance matrices on input quantities (usually numpy arrays). In case the input quantity is an array of shape (m,o), the covariance matrix needs to be given as an array of shape (m*o,m*o).

  • param_fixed (list of bools, optional) – when repeat_dims>=0, set to true or false to indicate for each input quantity whether it has repeated measurements that should be split (param_fixed=False) or whether the input is fixed (param fixed=True), defaults to None (no inputs fixed).

  • corr_between (array, optional) – covariance matrix (n,n) between input quantities, defaults to None

  • samples (list[array], optional) – allows to provide a Monte Carlo sample previously generated. This sample of input quantities will be used instead of generating one from the uncertainties and error-correlation. Defaults to None

  • return_corr (bool, optional) – set to True to return correlation matrix of measurand, defaults to True

  • return_samples (bool, optional) – set to True to return generated samples, defaults to False

  • repeat_dims (integer or list of 2 integers, optional) – set to positive integer(s) to select the axis which has repeated measurements. The calculations will be performed seperately for each of the repeated measurments and then combined, in order to save memory and speed up the process. Defaults to -99, for which there is no reduction in dimensionality..

  • corr_dims (integer, optional) – set to positive integer to select the axis used in the correlation matrix. The correlation matrix will then be averaged over other dimensions. Defaults to -99, for which the input array will be flattened and the full correlation matrix calculated. When the combined correlation of 2 or more (but not all) dimensions is required, they can be provided as a string containing the different dimension integers, separated by a dot (e.g. “0.2”). When multiple error_correlations should be calculated, they can be provided as a list.

  • separate_corr_dims (bool, optional) – When set to True and output_vars>1, corr_dims should be a list providing the corr_dims for each output variable, each following the format defined in the corr_dims description. Defaults to False

  • fixed_corr_var (bool or integer, optional) – set to integer to copy the correlation matrix of the dimiension the integer refers to. Set to True to automatically detect if only one uncertainty is present and the correlation matrix of that dimension should be copied. Defaults to False.

  • output_vars (integer, optional) – number of output parameters in the measurement function. Defaults to 1.

  • PD_corr (bool, optional) – set to True to make sure returned correlation matrices are positive semi-definite, default to True

  • refyvar (int, optional) – Index of output variable with reference shape (only relevant when output_vars>1; should be output variable with most dimensions; affects things like repeat_dims)

  • pdf_shape (str, optional) – string identifier of the probability density function shape, defaults to gaussian

  • pdf_params (dict, optional) – dictionaries defining optional additional parameters that define the probability density function, Defaults to None (gaussian does not require additional parameters)

Returns:

uncertainties on measurand

Return type:

array