Bootstrapping

unite_toolbox.utils.bootstrapping.density_bootstrap(x: numpy.ndarray, data: numpy.ndarray, estimator: collections.abc.Callable, n_bootstraps: int, significance: float, seed: int | None = None, *, add_noise: bool = False, **kwargs: dict[str, Any]) tuple[float, list[float]]

Calculate density with bootstrap confidence intervals.

Calculates density at x with confidence intervals defined by significance. An estimator to calculate density has to be passed as a callable function. add_noise is required for a k-NN based estimator.

Parameters

xnp.ndarray

Array of shape (n_samples, d_features)

datanp.ndarray

Array of shape (n_samples, d_features)

estimatorCallable function

Density estimator function

n_bootstrapsint

No. of bootstraps to perform

significancefloat

Statistical significance for confidence intervals

seedint, optional

Seed for random number generator

add_noisebool, optional

Flag to add noise to data if required

**kwargs: dict[str, Any]

Keyword arguments for the estimator

Returns

bs_meanfloat

Mean density from the bootstrap

bs_cilist[float]

Lower and upper quantiles of the bootstrap

unite_toolbox.utils.bootstrapping.one_sample_bootstrap(data: numpy.ndarray, estimator: collections.abc.Callable, n_bootstraps: int, significance: float, seed: int | None = None, *, add_noise: bool = False, **kwargs: dict[str, Any]) tuple[float, list[float]]

Calculate entropy with bootstrap confidence intervals.

Calculates a bootstrap result of the estimator with confidence intervals defined by significance. add_noise is required for a k-NN. The estimator must applicable to only one sample, i.e., data.

Parameters

datanp.ndarray

Array of shape (n_samples, d_features)

estimatorCallable function

Density estimator function

n_bootstrapsint

No. of bootstraps to perform

significancefloat

Statistical significance for confidence intervals

seedint, optional

Seed for random number generator

add_noisebool, optional

Flag to add noise to data if required

**kwargs: dict[str, Any]

Keyword arguments for the estimator

Returns

bs_meanfloat

Mean density from the bootstrap

bs_cilist[float]

Lower and upper quantiles of the bootstrap