Skip to main content

DistributionProvider

Trait DistributionProvider 

Source
pub trait DistributionProvider {
    // Required methods
    fn probability(
        &self,
        spec: &FactorSpec<'_>,
        assignment: &Assignment,
        ctx: &EvalContext,
    ) -> Result<f64, EvalError>;
    fn support(
        &self,
        vars: &[VariableId],
        ctx: &EvalContext,
    ) -> Result<Arc<[Arc<[Value]>]>, EvalError>;
    fn outcome(
        &self,
        var: VariableId,
        assignment: &Assignment,
        ctx: &EvalContext,
    ) -> Result<f64, EvalError>;
    fn n_draws(&self) -> Option<usize>;

    // Provided method
    fn quadrature(
        &self,
        _vars: &[VariableId],
        _ctx: &EvalContext,
    ) -> Result<Option<QuadratureNodes>, EvalError> { ... }
}
Expand description

Provides densities, discrete supports, and outcome values for evaluation.

Required Methods§

Source

fn probability( &self, spec: &FactorSpec<'_>, assignment: &Assignment, ctx: &EvalContext, ) -> Result<f64, EvalError>

Probability / density mass for a factor under an assignment.

§Errors

Missing table entries, bad draw index, or shape errors.

Source

fn support( &self, vars: &[VariableId], ctx: &EvalContext, ) -> Result<Arc<[Arc<[Value]>]>, EvalError>

Discrete support for variables (cartesian rows of values aligned to vars).

§Errors

Empty domains or unsupported queries.

Source

fn outcome( &self, var: VariableId, assignment: &Assignment, ctx: &EvalContext, ) -> Result<f64, EvalError>

Outcome function value (identity: the bound value of var).

§Errors

Missing binding or non-numeric value.

Source

fn n_draws(&self) -> Option<usize>

Number of posterior draws, or None for a single empirical world.

Provided Methods§

Source

fn quadrature( &self, _vars: &[VariableId], _ctx: &EvalContext, ) -> Result<Option<QuadratureNodes>, EvalError>

Optional continuous quadrature nodes (assignment_row, Lebesgue weight) for crate::ExprNode::IntegralOut.

Returning Ok(None) asks the evaluator to fall back to discrete Self::support.

§Errors

Provider-specific continuous-integration failures.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§