Skip to main content

Inference

Trait Inference 

Source
pub trait Inference {
    type Mat: IoOps + MeltOps + CandleDataLoaderOps;
    type Scalar: Into<f32>;

    // Required methods
    fn posterior_mean(&self) -> &Self::Mat;
    fn posterior_sd(&self) -> &Self::Mat;
    fn posterior_log_mean(&self) -> &Self::Mat;
    fn posterior_log_sd(&self) -> &Self::Mat;
    fn posterior_sample(&self) -> Result<Self::Mat>;
    fn posterior_log_sample(&self, seed: u64) -> Result<Self::Mat>;
    fn nrows(&self) -> usize;
    fn ncols(&self) -> usize;

    // Provided method
    fn posterior_sample_seeded(&self, seed: u64) -> Result<Self::Mat> { ... }
}

Required Associated Types§

Required Methods§

Source

fn posterior_mean(&self) -> &Self::Mat

Source

fn posterior_sd(&self) -> &Self::Mat

Source

fn posterior_log_mean(&self) -> &Self::Mat

Source

fn posterior_log_sd(&self) -> &Self::Mat

Source

fn posterior_sample(&self) -> Result<Self::Mat>

Source

fn posterior_log_sample(&self, seed: u64) -> Result<Self::Mat>

Draw a fresh sample of log λ per element. Delta-method approximation: log λ ≈ Normal(posterior_log_mean, posterior_log_sd²). Caller must have called calibrate_with(CalibrateTarget::All) first so log_mean / log_sd are populated.

seed makes the draw reproducible. It used to come from rand::rng() inside a map_init, which is OS-seeded AND partitioned by rayon, so a caller could not reproduce its own null distribution even with every other seed pinned. Seeding per CHUNK rather than per element keeps the draw parallel and independent of how rayon happens to split the work.

Source

fn nrows(&self) -> usize

Source

fn ncols(&self) -> usize

Provided Methods§

Source

fn posterior_sample_seeded(&self, seed: u64) -> Result<Self::Mat>

Self::posterior_sample drawn from seed: the same seed gives the same matrix, whatever the thread count, so a fit trained on it replays. Seeded per fixed-width chunk, like Self::posterior_log_sample.

The default refuses: an implementation outside this crate that predates the method has no seeded draw.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Inference for legume_numeric::param::dmatrix_gamma::GammaMatrix

Source§

impl Inference for legume_numeric::param::ndarray_gamma::GammaMatrix