[−][src]Struct genevo::random::WeightedDistribution
The WeightedDistribution
is used to select values proportional to their
weighted values.
The values in a WeightedDistribution
must have a scalar representation.
Thus their types must implement the genetic::AsScalar
trait. The weights
of the values are calculated from their scalar representation.
Methods
impl<'a, T> WeightedDistribution<'a, T> where
T: 'a + AsScalar,
[src]
T: 'a + AsScalar,
pub fn from_scalar_values(values: &'a [T]) -> Self
[src]
Constructs a new instance of WeightedDistribution
for the given slice
of values.
pub fn select(&self, pointer: f64) -> usize
[src]
Selects a value proportional to its weight and returns its index.
The pointer must be a float between 0 und the sum of the weights of all values. Usually the pointer is chosen uniformly at random.
pub fn sum(&self) -> f64
[src]
Returns the sum of the weights of all values in this
WeightedDistribution
instance.
The sum is calculated from the scalar values of the slice that was used
to create this WeightedDistribution
instance.
pub fn value(&self, index: usize) -> &T
[src]
Returns a reference to the value at the given index.
Trait Implementations
impl<'a, T: PartialEq> PartialEq<WeightedDistribution<'a, T>> for WeightedDistribution<'a, T> where
T: 'a + AsScalar,
[src]
T: 'a + AsScalar,
fn eq(&self, other: &WeightedDistribution<'a, T>) -> bool
[src]
fn ne(&self, other: &WeightedDistribution<'a, T>) -> bool
[src]
impl<'a, T: Clone> Clone for WeightedDistribution<'a, T> where
T: 'a + AsScalar,
[src]
T: 'a + AsScalar,
fn clone(&self) -> WeightedDistribution<'a, T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a, T: Debug> Debug for WeightedDistribution<'a, T> where
T: 'a + AsScalar,
[src]
T: 'a + AsScalar,
Auto Trait Implementations
impl<'a, T> Send for WeightedDistribution<'a, T> where
T: Sync,
T: Sync,
impl<'a, T> Sync for WeightedDistribution<'a, T> where
T: Sync,
T: Sync,
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,