gameanalysis.bootstrap module¶
Module for using bootstrap in analysis
-
gameanalysis.bootstrap.
game_function
(game, function, num_resamples, num_returned, *, percentiles=None, processes=None)[source]¶ Bootstrap the value of a function over a sample game
- Parameters
game (SampleGame) – The sample game to bootstrap the function value over.
function (f(Game) -> float or f(Game) -> [float]) – The function of the game to compute. It must be pickleable unless processes is 1, and it must return either a float or an iterable of floats. If an iterable of floats, this bootstrap all indices of the return value independently.
num_resamples (int) – The number of bootstrap samples. Higher will take longer but also give better accuracy.
num_returned (int) – The number of float values your function returns.
percentiles (int or [int]) – The percentiles to compute on the resulting data in [0, 100]. Standard percentiles are 95, or [2.5, 97.5]. By default, return all samples.
processes (int (optional)) – The number of processes to use for computation. By default this is the number of cores.
- Returns
bootstrap_percentiles – An ndarray of the percentiles from bootstrapping. The shape will depend on the number of percentiles and the number of values returned from your function.
- Return type
ndarray
-
gameanalysis.bootstrap.
mixture_regret
(game, mixtures, num_resamples, *, percentiles=None, processes=None)[source]¶ Compute percentile bounds on mixture regret
- Parameters
game (SampleGame) – The sample game to bootstrap the function value over.
mixtures (ndararay) – The profiles to compute mixture regret bounds for.
num_resamples (int) – The number of bootstrap samples. Higher will take longer but also give better accuracy.
percentiles (int or [int]) – The percentiles to compute on the resulting data in [0, 100]. Standard percentiles are 95, or [2.5, 97.5]. By default, return all samples.
processes (int (optional)) – The number of processes to use for computation. By default this is the number of cores.
- Returns
regret_percentiles – An ndarray of the percentiles for bootstrap regret for each profile.
- Return type
ndarray
-
gameanalysis.bootstrap.
mixture_welfare
(game, mixtures, num_resamples, *, percentiles=None, processes=None)[source]¶ Compute percentile bounds on mixture welfare
- Parameters
game (SampleGame) – The sample game to bootstrap the function value over.
mixtures (ndarray) – The profiles to compute mixture welfare bounds for.
num_resamples (int) – The number of bootstrap samples. Higher will take longer but also give better accuracy.
percentiles (int or [int]) – The percentiles to compute on the resulting data in [0, 100]. Standard percentiles are 95, or [2.5, 97.5]. By default, return all samples.
processes (int (optional)) – The number of processes to use for computation. By default this is the number of cores.
- Returns
bootstrap_percentiles – An ndarray of the percentiles for bootstrap welfare for each profile.
- Return type
ndarray
-
gameanalysis.bootstrap.
profile_function
(game, function, profiles, num_resamples, *, percentiles=None, processes=None)[source]¶ Compute a function over profiles
- Parameters
game (SampleGame) – The sample game to bootstrap the function value over.
function (Game, profile -> float) – The function of the game profile pair to compute. It must be pickleable, and it must return a float (e.g. regret.mixture_regret).
profiles (ndarray) – The profiles to compute bootstrap bounds over for function.
num_resamples (int) – The number of bootstrap samples. Higher will take longer but also give better accuracy.
percentiles (int or [int]) – The percentiles to compute on the resulting data in [0, 100]. Standard percentiles are 95, or [2.5, 97.5]. By default, return all samples.
processes (int (optional)) – The number of processes to use for computation. By default this is the number of cores.
- Returns
bootstrap_percentiles – An ndarray of the percentiles from bootstrapping for each profile. The shape will depend on the number of percentiles and the number of profiles.
- Return type
ndarray