Workspace/Coding labs
Loading progress

Bootstrap a paired candidate difference

Intermediate65 min

Given equal-length paired finite numeric outcomes, estimate the mean of B minus A. Resample task indices with replacement, preserving each pair, for a deterministic local seed. Each resample has the original task count. Return difference, low/high central percentile-bootstrap endpoints using nearest-rank indexing, and tasks. Validate nonempty equal lengths, finite numbers excluding booleans, repeats at least two, and confidence strictly between zero and one. This small method does not guarantee coverage for tiny, biased, or dependent samples.

Your task

  1. Complete the starter function using the contract above.
  2. Use the examples and visible tests to check normal inputs, boundaries, and rejected inputs.
  3. Run tests to record your result, then compare with the explained reference solution.

Examples

EXAMPLE 1

InputA=[1,0,1,0,1], B=[1,1,1,0,1]

Outputdifference .2; interval includes zero with supplied seed/configuration

One discordant task provides limited evidence.
EXAMPLE 2

InputAll paired differences equal one

Outputdifference=low=high=1

The empirical bootstrap cannot invent unobserved variation.
solution.pyPython 3.12