Skip to main content

bootstrap

Function bootstrap 

Source
pub fn bootstrap<T>(
    x: &ArrayView1<'_, T>,
    n_resamples: usize,
    seed: Option<u64>,
) -> StatsResult<Array2<T>>
where T: Copy + Zero,
Expand description

Nonparametric bootstrap

§Arguments

  • x - Input array
  • n_resamples - Number of bootstrap samples to generate
  • seed - Optional seed for reproducibility

§Returns

  • Bootstrap samples with replacement

§Examples

use scirs2_core::ndarray::array;
use scirs2_stats::sampling;

// Create an array
let data = array![1.0, 2.0, 3.0, 4.0, 5.0];

// Generate bootstrap samples
let samples = sampling::bootstrap(&data.view(), 10, Some(42)).expect("Operation failed");
assert_eq!(samples.shape(), &[10, 5]);