Trait constriction::stream::model::Distribution
source · [−]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
Distributiontrait from theprobabilitycrate. You’ll need a type that implementsDistributionwhen you callLeakyQuantizer::quantize. Theprobabilitycrate provides implementations of several commonDistributions. - Unfortunately, the
probabilitycrate does not supportno_stdmode. Thus, if you compileconstrictioninno_stdmode (by settingdefault-features = falseforconstrictionin yourCargo.toml) then you can’t use theprobabilitycrate . In this case, the present trait (constriction::stream::model::Distribution) is not a re-export but instead a literal copy of its definition in theprobabilitytrait.
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
Required Methods
sourcefn distribution(&self, x: f64) -> f64
fn distribution(&self, x: f64) -> f64
Compute the cumulative distribution function.