Module: bootstrap

Resampling statistics: bootstrap confidence intervals and permutation tests, as scipy.stats.bootstrap and scipy.stats.permutation_test.

Source:

Methods

(static) bootstrap(data, statisticopt, optionsopt) → {BootstrapResult}

Bootstrap estimate of the sampling distribution of a statistic.

Parameters:
Name Type Attributes Default Description
data Array

The sample.

statistic function <optional>
mean

Statistic computed on a sample.

options Object <optional>
Properties
Name Type Attributes Default Description
nResamples number <optional>
9999

Number of bootstrap resamples.

confidence number <optional>
0.95

Confidence level of the interval.

method string <optional>
'BCa'

'BCa' (bias-corrected and accelerated, scipy's default) or 'percentile'.

Source:
Returns:
Type
BootstrapResult
Example
const result = bootstrap(data, (xs) => median(xs), { nResamples: 5000 })
result.confidenceInterval   // [low, high]

(static) permutationTest(x, y, statisticopt, optionsopt) → {PermutationTestResult}

Two-sample permutation test of the null hypothesis that both samples come from the same distribution.

Parameters:
Name Type Attributes Description
x Array.<number>

First sample.

y Array.<number>

Second sample.

statistic function <optional>

Test statistic; difference of means by default.

options Object <optional>
Properties
Name Type Attributes Default Description
nResamples number <optional>
9999

Number of random permutations.

alternative string <optional>
'two-sided'

'two-sided', 'greater' or 'less'.

Source:
Returns:
Type
PermutationTestResult
Example
permutationTest(control, treatment).pvalue

Type Definitions

BootstrapResult

Type:
  • Object
Properties:
Name Type Description
estimate number

The statistic on the original data.

standardError number

Standard deviation of the bootstrap distribution.

bias number

Mean of the bootstrap distribution minus the estimate.

confidenceInterval Array.<number>

[lower, upper] bounds.

distribution Array.<number>

The bootstrap replicates of the statistic.

Source:

PermutationTestResult

Type:
  • Object
Properties:
Name Type Description
statistic number

The observed statistic.

pvalue number

The permutation p-value.

nullDistribution Array.<number>

Statistic values under random relabelling.

Source: