MCPcopy Create free account
hub / github.com/apache/arrow-rs / create_f64_array_with_seed

Function create_f64_array_with_seed

arrow/src/util/bench_util.rs:861–873  ·  view source on GitHub ↗

Creates a random f64 array of a given size and nan-value density based on a given seed

(size: usize, nan_density: f32, seed: u64)

Source from the content-addressed store, hash-verified

859
860/// Creates a random f64 array of a given size and nan-value density based on a given seed
861pub fn create_f64_array_with_seed(size: usize, nan_density: f32, seed: u64) -> Float64Array {
862 let mut rng = StdRng::seed_from_u64(seed);
863
864 (0..size)
865 .map(|_| {
866 if rng.random::<f32>() < nan_density {
867 Some(f64::NAN)
868 } else {
869 Some(rng.random())
870 }
871 })
872 .collect()
873}

Calls 2

collectMethod · 0.80
randomMethod · 0.80

Tested by

no test coverage detected