pub struct WeightedDistribution<'a, T> where
    T: 'a + AsScalar
{ /* private fields */ }
Expand description

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.

Implementations

Constructs a new instance of WeightedDistribution for the given slice of values.

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.

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.

Returns a reference to the value at the given index.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.