comet_maths.generate_sample.generate_sample.correlate_sample_corr

comet_maths.generate_sample.generate_sample.correlate_sample_corr#

comet_maths.generate_sample.generate_sample.correlate_sample_corr(sample, corr, mean=None, std=None, dtype=None, iterate_sample=False, maintain_sample_unmodified=False)[source]#

Method to correlate independent sample of input quantities using correlation matrix and Cholesky decomposition.

Parameters:
  • sample (array[array]) – independent sample of input quantities

  • corr (array) – correlation matrix between input quantities

  • mean (array) – mean from which the sample has been drawn. Defaults to None, in which case the mean of the provided sample is taken (can be very imprecise for samples with few draws).

  • std (array) – standard eviation used when generating the sample. Defaults to None, in which case the std of the provided sample is taken (can be very imprecise for samples with few draws).

  • dtype (numpy.dtype, optional) – dtype of the produced sample

  • iterate_sample (bool, optional) – boolean to indicate if comet_maths should iterate over the different samples when introducing correlation. (This is more time-consuming but might be necessary if the different samples have different error correlations), defaults to False.

  • maintain_sample_unmodified (bool, optional) – boolean to indicate if the provided sample must remain unchanged (as opposed to introducing correlation). This requires a full copy of the sample, and thus doubles the memory required. Defaults to False.

Returns:

correlated sample of input quantities

Return type:

array[array]