pub fn bootstrap_sample<T>(
x: &ArrayView1<'_, T>,
n_samples_: usize,
seed: Option<u64>,
) -> StatsResult<Array2<T>>Expand description
Generate a bootstrap sample from an array
§Arguments
x- Input arrayn_samples_- Number of bootstrap samples to generateseed- Optional seed for reproducibility
§Returns
- Bootstrap samples with replacement
§Examples
use scirs2_core::ndarray::array;
use scirs2_stats::random::bootstrap_sample;
// Create an array
let data = array![1.0, 2.0, 3.0, 4.0, 5.0];
// Generate 10 bootstrap samples
let samples = bootstrap_sample(&data.view(), 10, Some(42)).expect("Operation failed");
// Each bootstrap sample should have the same length as the original data
assert_eq!(samples.shape(), &[10, 5]);