Skip to main content

parallel_uniform_sample

Function parallel_uniform_sample 

Source
pub fn parallel_uniform_sample(
    n: usize,
    low: f64,
    high: f64,
    seed: Option<u64>,
) -> StatsResult<Vec<f64>>
Expand description

Generate n independent samples from U(low, high) using parallel threads and per-thread SIMD linear-rescaling kernels.

Each chunk receives a deterministic seed derived from the base seed and the chunk index for full reproducibility.

§Arguments

  • n — Total number of samples.
  • low — Lower bound (inclusive).
  • high — Upper bound (exclusive; must be strictly greater than low).
  • seed — Optional base RNG seed.

§Errors

Returns StatsError::InvalidArgument when n == 0 or low >= high.

§Examples

use scirs2_stats::simd_sampling::parallel_uniform_sample;

let samples = parallel_uniform_sample(10_000, 0.0_f64, 1.0_f64, Some(7))
    .expect("parallel sampling failed");
assert_eq!(samples.len(), 10_000);
assert!(samples.iter().all(|&x| x >= 0.0 && x < 1.0));