pub trait Distribution {
    type Value;

    fn distribution(&self, x: f64) -> f64;
}
Expand description

Re-export or replacement of probability::distribution::Distribution.

Most users will never have to interact with this trait directly. When a method requires a type that implements Distribution, most users will likely use a predefined type from the probability crate. You only need to implement this trait if you want to use a probability distribution that is not (yet) provided by the probability crate.

Technical Details

  • For most users, this trait is just a re-export (similar to a type alias) of the Distribution trait from the probability crate. You’ll need a type that implements Distribution when you call LeakyQuantizer::quantize. The probability crate provides implementations of several common Distributions.
  • Unfortunately, the probability crate does not support no_std mode. Thus, if you compile constriction in no_std mode (by setting default-features = false for constriction in your Cargo.toml) then you can’t use the probability crate . In this case, the present trait (constriction::stream::model::Distribution) is not a re-export but instead a literal copy of its definition in the probability trait.

Advice for Implementors

If you implement your own probability distribution (rather than using a pre-defined distribution from the probability crate) then it is usually better to implement this trait rather than probability::distribution::Distribution. This way, your code will work as expected both in std and in no_std mode.

See Also

A distribution.

Required Associated Types

The type of outcomes.

Required Methods

Compute the cumulative distribution function.

Implementors