Struct set_genome::GenomeRng [−][src]
pub struct GenomeRng { /* fields omitted */ }
This struct serves as the randomness source for all operations.
Implementations
impl GenomeRng
[src]
impl GenomeRng
[src]pub fn new(seed: u64, std_dev: f64, cap: f64) -> Self
[src]
Creates a GenomeRng
.
seed
is specified for reproducibility of experiments.
std_dev
configures the standard deviation of the normal distribution from which the weight perturbations are sampled.
cap
specifies the upper and lower bound of values returned from GenomeRng::weight_perturbation
.
use set_genome::GenomeRng; let genome_rng = GenomeRng::new(42, 0.1, 1.0);
pub fn gamble(&mut self, chance: f64) -> bool
[src]
Returns true chance
percent of the time.
// a coin flip if genome_rng.gamble(0.5) { println!("heads") } else { println!("tails") } // the following always happens, gambling with 100% chance to succeed assert!(genome_rng.gamble(1.0), "I should always win!");
pub fn weight_perturbation(&mut self, weight: f64) -> f64
[src]
Returns the weight
altered by some random value.
let mut genome_rng = GenomeRng::new(42, 0.1, 1.0); // random_weight will probably be some small value, // definitely not bigger than 1.0 or smaller than -1.0. let random_weight = genome_rng.weight_perturbation(0.0);
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for GenomeRng
impl RefUnwindSafe for GenomeRng
impl UnwindSafe for GenomeRng
impl UnwindSafe for GenomeRng
Blanket Implementations
impl<R> Rng for R where
R: RngCore + ?Sized,
[src]
impl<R> Rng for R where
R: RngCore + ?Sized,
[src]pub fn gen<T>(&mut self) -> T where
Standard: Distribution<T>,
[src]
Standard: Distribution<T>,
pub fn gen_range<T, R>(&mut self, range: R) -> T where
T: SampleUniform,
R: SampleRange<T>,
[src]
T: SampleUniform,
R: SampleRange<T>,
pub fn sample<T, D>(&mut self, distr: D) -> T where
D: Distribution<T>,
[src]
D: Distribution<T>,
pub fn sample_iter<T, D>(self, distr: D) -> DistIter<D, Self, T> where
D: Distribution<T>,
[src]
D: Distribution<T>,
pub fn fill<T>(&mut self, dest: &mut T) where
T: Fill + ?Sized,
[src]
T: Fill + ?Sized,
pub fn try_fill<T>(&mut self, dest: &mut T) -> Result<(), Error> where
T: Fill + ?Sized,
[src]
T: Fill + ?Sized,
pub fn gen_bool(&mut self, p: f64) -> bool
[src]
pub fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,