- qspec. propagate ( f , x , x_d=None , cov=None , unc_places=None , sample_size=1000000 , rtol=0.001 , atol=None , force_sym=False , full_output=False , show=False )[source]
-
Propagate the uncertainties of the input values
xthrough the functionfusing Monte-Carlo sampling.If the resulting uncertainties are asymmetric, the value and the two uncertainties of the returned
Observableare the median and the left- (~0.1587) and right-sided (~0.8413) 1-sigma percentiles relative to the median, respectively, and the parameters of a skew normal distribution are fitted to the sample and stored in the observable. If the uncertainties are symmetric, the observable is assumed to be normally distributed and its value and uncertainty are the mean and the standard deviation of the sample.- Parameters:
-
- fCallable
The function to compute.
fneeds to be vectorized.- xIterable[scalar]
The input values. If
x_disNone, the sample data is generated withObservable.rvs, which considers asymmetric uncertainties. If an element is not anObservable, its uncertainty is assumed to be 0.- x_darray_like | None
The uncertainties of the input values.
- covscalar_nd | None
The covariance matrix of the input values. If not
None,xis assumed to be distributed according to a multivariate normal distribution with covariancecov.- unc_placesint_like | None
The number of significant decimal places the result will be rounded to. If
None, the result is not rounded.- sample_sizeint_like
The number of random variates used for the calculation. The default is 1,000,000.
- rtolfloat
The relative tolerance, with respect to the median of the resulting sample, with which the left- and right-sided uncertainties can deviate before asymmetric uncertainties are used.
- atolfloat | None
The absolute tolerance with which the left- and right-sided uncertainties can deviate, before asymmetric uncertainties are used. Overrides
rtol.- force_symbool
Whether to force symmetric uncertainties. If so, a normal distribution is assumed.
- full_outputbool
Whether to return the randomly generated data samples.
- showbool
Whether to show a histogram and estimated pdfs of the computed sample data.
- Returns:
-
- (ob, x_samples, y_samples)Observable | tuple[Observable, ndarray, ndarray]
An
Observablewhose uncertainties result from the propagation of the uncertainties of the input valuesxby the functionf. Iffull_outputisTrue, the input samples and the output sample are returned as well.
- Raises:
-
- ValueError
If
xandx_dhave different sizes.