Skip to content

support sampling with and without replacement#58

Merged
SpatLyu merged 11 commits into
stscl:mainfrom
SpatLyu:dev
Apr 4, 2026
Merged

support sampling with and without replacement#58
SpatLyu merged 11 commits into
stscl:mainfrom
SpatLyu:dev

Conversation

@SpatLyu

@SpatLyu SpatLyu commented Apr 4, 2026

Copy link
Copy Markdown
Member

This PR refactors the library sampling logic used in the bootstrap procedure to ensure statistical correctness and improve flexibility.

Key changes

  1. Add support for sampling with replacement (bootstrap)

    • When replace_sampling == true, library indices are now sampled with replacement using a uniform distribution
    • This aligns with standard bootstrap methodology for estimating sampling distributions and confidence intervals
  2. Retain subsampling (without replacement) as an alternative mode

    • When replace_sampling == false, the existing shuffle-based subsampling strategy is preserved
    • This is useful for library size sensitivity analysis and robustness checks
  3. Deterministic behavior when boot == 1

    • When only one bootstrap iteration is requested, the library is taken as the first L indices without randomization
    • This ensures reproducibility and avoids unnecessary overhead

Motivation

Previously, the implementation only supported sampling without replacement, which corresponds to subsampling rather than true bootstrap. This can underestimate variability and lead to biased confidence intervals, especially for nonlinear statistics such as pattern causality measures.

By introducing proper bootstrap sampling:

  • The estimated distribution of causality metrics better reflects sampling variability
  • Confidence intervals derived from bootstrap replicates become statistically valid

Notes

  • The current implementation resamples only the library indices, while keeping prediction indices fixed. This follows the existing workflow, though future improvements may consider joint resampling strategies depending on the underlying data assumptions.

@SpatLyu SpatLyu self-assigned this Apr 4, 2026
@SpatLyu
SpatLyu merged commit 7226a02 into stscl:main Apr 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant