deerlab.bootstrap_analysis

bootstrap_analysis(fcn, Vexp, Vfit, samples=1000, noiselvl=None, resampling='gaussian', verbose=False, cores=1, memorylimit=8)[source]

Bootstrap analysis for uncertainty quantification

This function creates new synthetic datasets by using the noiseless model prediction Vfit and adding noise, according to the specified method. The fcn function is then applied to each of the new datasets to calculate the uncertainty of the variables returned by fcn.

Parameters:
fcncallable

Function to be analyzed. Must be a callable function fcn(V) accepting a dataset array as input and returning a tuple with all variables to be analyzed. All variables must be numerical arrays (no strings or booleans) and must preserve shape between calls.

Vexparray_like or list of array_like

Experimental dataset(s).

Vfitarray or list of array_like

Fit of the dataset(s).

samplesscalar, optional

Number of bootstrap samples to analyze. The quality of bootstrapping results improve with the number of boostrap samples evaluated, the default is 1000.

noiselvlscalar or list thereof

Noise level of the input dataset(s), specified as standard deviations. If not specified, these are automatically estimated from the experimental dataset(s).

resamplingstring, optional

Specifies the method employed for re-sampling new bootstrap samples.

  • 'gaussian' - Sample noise from a Gaussian distribution.

  • 'residual' - Sample noise from the fit residuals.

The default is 'gaussian'.

coresscalar, optional

Number of CPU cores/processes for parallel computing. If cores=1 no parallel computing is used. If cores=-1 all available CPUs are used. The default is one core (no parallelization).

verboseboolean, optional

Specifies whether to print the progress of the bootstrap analysis on the command window, the default is false.

memorylimit

Memory limit to be allocated for the full boostrap analysis. If the requested analysis exceeds this limit, the execution will be stopped. The default is 12GB.

Returns:
bootuqdeerlab.UQResult or list of deerlab.UQResult

Bootstrap uncertainty quantification for each variable returned by fcn.

Examples

To analyze several variables during the same run, the function must return tuple containing all of them:

def myfcn(V):
    Pfit1 = dl.nlls(V,dl.dd_gauss,r,K)
    Pfit2 = dl.nlls(V,dl.dd_randcoil,r,K)
    return Pfit1,Pfit2

bootuq = bootstrap_analysis(myfcn,V,Vfit)
Pfit1_uq = bootuq[0]
Pfit2_uq = bootuq[1]