pub fn bootstrap_sample(
n_samples: usize,
n_bootstrap_samples: usize,
random_seed: Option<u64>,
) -> Result<Vec<usize>>Expand description
Generate bootstrap samples from indices
This is a convenience function that generates bootstrap samples (sampling with replacement) which is commonly used for bootstrap confidence intervals and ensemble methods.
§Arguments
n_samples- Total number of samples in the datasetn_bootstrap_samples- Number of bootstrap samples to generaterandom_seed- Optional random seed for reproducible sampling
§Returns
A vector of bootstrap sample indices
§Examples
use scirs2_datasets::utils::bootstrap_sample;
let bootstrap_indices = bootstrap_sample(100, 100, Some(42)).unwrap();
assert_eq!(bootstrap_indices.len(), 100);
// Some indices should appear multiple times (with high probability)
let mut unique_indices = bootstrap_indices.clone();
unique_indices.sort();
unique_indices.dedup();
assert!(unique_indices.len() < bootstrap_indices.len());