punpy.mc.mc_propagation.MCPropagation.propagate_standard

punpy.mc.mc_propagation.MCPropagation.propagate_standard#

MCPropagation.propagate_standard(func, x, u_x, corr_x, param_fixed=None, corr_between=None, samples=None, return_corr=False, 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, allow_some_nans=True)[source]#

Propagate uncertainties through measurement function with n input quantities. Correlations must be specified in corr_x. Input quantities can be floats, vectors (1d-array) or images (2d-array). Systematic uncertainties arise when there is full correlation between repeated measurements. There is a often also a correlation between measurements along the dimensions that is not one of the repeat_dims.

Parameters:
  • func (function) – measurement function

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

  • u_x (list[array]) – list of systematic uncertainties on input quantities (usually numpy arrays)

  • corr_x (list[array]) – list of correlation matrices (n,n) along non-repeating axis. Can be set to “rand” (diagonal correlation matrix), “syst” (correlation matrix of ones) or a custom correlation matrix.

  • 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) – correlation 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 False

  • 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 dimension 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)

  • allow_some_nans (bool, optional) – set to False to ignore any MC sample which has any nan’s in the measurand. Defaults to True, in which case only MC samples with only nan’s are ignored.

Returns:

uncertainties on measurand

Return type:

array