pub trait Empirical: Distribution {
// Required methods
fn draws(&self) -> &[f64];
fn sorted(&self) -> &[f64];
// Provided methods
fn mean_of(&self, f: impl Fn(f64) -> f64) -> f64 { ... }
fn var(&self, p: f64) -> Result<f64> { ... }
fn tvar(&self, p: f64) -> Result<f64> { ... }
fn distortion(&self, d: &Distortion) -> f64 { ... }
}Expand description
Operations that are exact on draws: any statistic of the empirical distribution.
Every result is exact for the draws and an estimate of the distribution
they came from. Operations that are exact only on a parametric or
discretized distribution (limited expected value, layers) are not
offered here; a caller who wants an estimate from draws asks for it
with Empirical::mean_of.
Required Methods§
Provided Methods§
Sourcefn mean_of(&self, f: impl Fn(f64) -> f64) -> f64
fn mean_of(&self, f: impl Fn(f64) -> f64) -> f64
Mean of f(x) over the draws.
use prospicio_prob::{Empirical, Sampled};
let s = Sampled::new(vec![50.0, 150.0, 400.0]).unwrap();
// Estimated limited expected value at 100.
assert_eq!(s.mean_of(|x| x.min(100.0)), 250.0 / 3.0);Sourcefn distortion(&self, d: &Distortion) -> f64
fn distortion(&self, d: &Distortion) -> f64
Distortion risk measure of the draws; see
Distortion::apply_sorted.
use prospicio_prob::{Distortion, Empirical, Sampled};
let s = Sampled::new(vec![3.0, 1.0, 4.0, 2.0]).unwrap();
let tvar = Distortion::tvar(0.5).unwrap();
assert_eq!(s.distortion(&tvar), s.tvar(0.5).unwrap());Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".