Skip to main content

Likelihood

Struct Likelihood 

Source
pub struct Likelihood { /* private fields */ }
Expand description

A resolved collection of likelihood terms sharing one parameter layout.

Implementations§

Source§

impl Likelihood

Source

pub fn cross_section( self: &Arc<Likelihood>, term_name: impl Into<String>, generated_mc: Dataset, luminosity: f64, parameters: Vec<f64>, ) -> Result<CrossSection, LikelihoodError>

Prepares a central-value cross-section analysis from a shared likelihood.

§Errors

Returns an error for invalid inputs or likelihood preparation failure.

Source

pub fn cross_section_with_ensemble( self: &Arc<Likelihood>, term_name: impl Into<String>, generated_mc: Dataset, luminosity: f64, parameters: Vec<f64>, ensemble: Ensemble, ) -> Result<CrossSection, LikelihoodError>

Prepares an ensemble-backed cross-section analysis.

§Errors

Returns an error for invalid inputs, mismatched draws, or preparation failure.

Source§

impl Likelihood

Source

pub fn new<T>( terms: impl IntoIterator<Item = T>, ) -> Result<Likelihood, LikelihoodError>
where T: LikelihoodTerm + 'static,

Construct a likelihood from terms of one concrete type.

The terms are boxed internally, so the common case does not require a manual LikelihoodTerm::boxed call.

§Errors

Returns LikelihoodError when term names or parameter definitions conflict, or a term cannot be resolved.

Source

pub fn new_boxed( terms: impl IntoIterator<Item = Box<dyn LikelihoodTerm>>, ) -> Result<Likelihood, LikelihoodError>

Construct a likelihood containing heterogeneous, already boxed terms.

§Errors

Returns LikelihoodError when term names or parameter definitions conflict, or a term cannot be resolved.

Source

pub fn with_execution<T>( terms: impl IntoIterator<Item = T>, execution: &Execution, ) -> Result<Likelihood, LikelihoodError>
where T: LikelihoodTerm + 'static,

Constructs a likelihood with an explicit execution context.

§Errors

Returns LikelihoodError when term names or parameter definitions conflict, or a term cannot be resolved for execution.

Source

pub fn with_execution_boxed( terms: impl IntoIterator<Item = Box<dyn LikelihoodTerm>>, execution: &Execution, ) -> Result<Likelihood, LikelihoodError>

Construct a heterogeneous likelihood using a borrowed execution setup.

§Errors

Returns LikelihoodError when term names or parameter definitions conflict, or a term cannot be resolved for execution.

Source

pub fn params(&self) -> &ParamLayout

Returns the global parameter layout.

Source

pub fn default_params(&self) -> Vec<f64>

Return deterministic initial values in the order expected by Self::nll.

Source

pub fn params_with(&self, value: impl FnMut(&Parameter) -> f64) -> Vec<f64>

Generate one value for each free parameter in objective-vector order.

Source

pub fn sample_initial(&self, seed: u64) -> Vec<f64>

Sample uniform initial ranges while preserving fixed and point-initialized parameters.

Source

pub fn bootstrap(&self, seed: u64) -> Result<Likelihood, LikelihoodError>

Rebuilds this likelihood with Poisson-bootstrapped observed datasets.

§Errors

Returns LikelihoodError when a term cannot be bootstrap-cloned or the rebuilt likelihood cannot be prepared.

Source

pub fn terms(&self) -> &[Box<dyn LikelihoodTerm>]

Returns the resolved likelihood terms.

Source

pub fn execution(&self) -> &Execution

Returns the execution context used by the likelihood.

Source

pub fn diagnostics(&self) -> LikelihoodDiagnostics

Returns a snapshot of preparation and objective-evaluation diagnostics.

Source

pub fn nll<'a>( &self, parameters: impl Into<Parameters<'a>>, ) -> Result<f64, LikelihoodError>

Evaluate the objective from free values in Self::params order.

§Errors

Returns LikelihoodError when parameters have the wrong layout or length, violate bounds, or a term cannot be evaluated.

Source

pub fn nll_with_gradient<'a>( &self, parameters: impl Into<Parameters<'a>>, ) -> Result<LikelihoodEvaluation, LikelihoodError>

Evaluates the objective and gradient from free or resolved parameter values.

§Errors

Returns LikelihoodError when parameters are invalid or a term’s value or gradient cannot be evaluated.

Source

pub fn stochastic_nll_with_gradient( &self, free_parameters: &[f64], fraction: f64, seed: u64, ) -> Result<LikelihoodEvaluation, LikelihoodError>

Evaluates an unbiased stochastic objective and gradient.

§Errors

Returns LikelihoodError when fraction is outside (0, 1], parameters are invalid, or stochastic term evaluation fails.

Source

pub fn cross_section_integrals( &self, term_name: &str, generated_mc: &Dataset, ) -> Result<CrossSectionIntegrals, LikelihoodError>

Prepares accepted and generated Monte Carlo integrals for an intensity term.

§Errors

Returns LikelihoodError when term_name is missing or not an intensity term, or dataset preparation fails.

Source

pub fn cross_section_integrals_with_tags<'a>( &self, term_name: &str, generated_mc: &Dataset, tags: impl IntoIterator<Item = &'a str>, ) -> Result<CrossSectionIntegrals, LikelihoodError>

Prepares tag-narrowed accepted and generated Monte Carlo integrals.

The selected tags define the numerator contribution. Cross sections retain the full accepted-model normalization, matching Self::projection.

§Errors

Returns LikelihoodError when term_name is missing or not an intensity term, graph projection fails, or dataset preparation fails.

Source

pub fn intensity_datasets( &self, term_name: &str, ) -> Result<(&Dataset, &Dataset), LikelihoodError>

Returns the observed and accepted Monte Carlo sources for an intensity term.

§Errors

Returns LikelihoodError when term_name is missing or is not an intensity term.

Source

pub fn projection<'a>( &self, term_name: &str, generated_mc: &Dataset, tags: impl IntoIterator<Item = &'a str>, ) -> Result<LikelihoodProjection, LikelihoodError>

Projects an intensity term onto selected model tags over generated Monte Carlo.

§Errors

Returns LikelihoodError when term_name is missing or not an intensity term, graph projection fails, or dataset preparation fails.

Trait Implementations§

Source§

impl Debug for Likelihood

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Objective for Likelihood

Source§

fn parameter_layout(&self) -> &ParamLayout

Returns the stable parameter layout used by objective vectors.
Source§

fn value(&self, free_parameters: &[f64]) -> Result<f64, LikelihoodError>

Evaluates the objective at the supplied free-parameter vector. Read more
Source§

fn value_gradient( &self, free_parameters: &[f64], ) -> Result<LikelihoodEvaluation, LikelihoodError>

Evaluates the objective and its gradient. Read more
Source§

impl StochasticObjective for Likelihood

Source§

fn stochastic_value_gradient( &self, free_parameters: &[f64], fraction: f64, seed: u64, ) -> Result<LikelihoodEvaluation, LikelihoodError>

Evaluates an unbiased stochastic objective and gradient on a deterministic batch. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.