Struct rand_simple::Uniform
source · pub struct Uniform { /* private fields */ }Expand description
一様乱数を計算する構造体
使用例 1 (new関数)
use rand_simple::Uniform;
let uniform = Uniform::new(1192u32);
let next = uniform.sample(); // 閉区間[0, 1]の一様乱数
println!("乱数: {}", next); // 0.8698977918526851f64使用例 2 (マクロ・引数有り)
use rand_simple::create_uniform;
let uniform = create_uniform!(1192u32);
let next = uniform.sample(); // 閉区間[0, 1]の一様乱数
println!("乱数: {}", next); // 0.8698977918526851f64使用例 3 (マクロ・引数無し)
use rand_simple::create_uniform;
let uniform = create_uniform!();
let next = uniform.sample(); // 閉区間[0, 1]の一様乱数
println!("乱数: {}", next); // 値不明Implementations§
source§impl Uniform
impl Uniform
sourcepub fn test_sample<T: TestUniformSample>(&self, foo: &T) -> f64
pub fn test_sample<T: TestUniformSample>(&self, foo: &T) -> f64
(試験運用)一様分布乱数を返すメソッド
オーバーロードテスト用
使用例
use rand_simple::Uniform;
let uniform = Uniform::new(1192u32);
// ↓確率変数のパラメータ無しを &() (unit tuple) で表現している
let next_default = uniform.test_sample(&());
println!("{}", next_default); // 引数が &() (unit tuple)の場合、閉区間[0, 1]で計算する
let min: f64 = 0f64;
let max: f64 = 2f64;
let next_custom = uniform.test_sample(&(min, max));
println!("{}", next_custom); // 引数が&(min, max)の場合、閉区間[min, max]で計算するtraitによるオーバーロードのテストメソッド
Auto Trait Implementations§
impl !RefUnwindSafe for Uniform
impl Send for Uniform
impl !Sync for Uniform
impl Unpin for Uniform
impl UnwindSafe for Uniform
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more