pub struct NLL {
pub data_evaluator: Evaluator,
pub accmc_evaluator: Evaluator,
/* private fields */
}Expand description
An extended, unbinned negative log-likelihood evaluator.
Fields§
§data_evaluator: EvaluatorThe internal Evaluator for data
accmc_evaluator: EvaluatorThe internal Evaluator for accepted Monte Carlo
Implementations§
Source§impl NLL
impl NLL
Sourcepub fn new(
expression: &Expression,
ds_data: &Arc<Dataset>,
ds_accmc: &Arc<Dataset>,
n_mc: Option<f64>,
) -> LadduResult<Box<Self>>
pub fn new( expression: &Expression, ds_data: &Arc<Dataset>, ds_accmc: &Arc<Dataset>, n_mc: Option<f64>, ) -> LadduResult<Box<Self>>
Construct an NLL from an Expression and two Datasets (data and Monte Carlo). This mirrors loading a model but starts from
the expression directly. The number of Monte Carlo events used in the denominator of the
normalization integral may also be specified (uses the weighted number of accepted Monte
Carlo events if None is given).
Sourcepub fn parameters(&self) -> ParameterMap
pub fn parameters(&self) -> ParameterMap
The parameters for this NLL.
Sourcepub fn n_parameters(&self) -> usize
pub fn n_parameters(&self) -> usize
Total number of parameters.
Sourcepub fn expression(&self) -> Expression
pub fn expression(&self) -> Expression
Returns the expression represented by this NLL.
Sourcepub fn compiled_expression(&self) -> CompiledExpression
pub fn compiled_expression(&self) -> CompiledExpression
Returns a tree-like diagnostic snapshot of the compiled expression for this NLL’s current active-amplitude mask.
Sourcepub fn to_stochastic(
&self,
batch_size: usize,
seed: Option<usize>,
) -> LadduResult<StochasticNLL>
pub fn to_stochastic( &self, batch_size: usize, seed: Option<usize>, ) -> LadduResult<StochasticNLL>
Create a new StochasticNLL from this NLL.
Sourcepub fn activate<T: AsRef<str>>(&self, name: T)
pub fn activate<T: AsRef<str>>(&self, name: T)
Activate an Amplitude by tag, skipping missing entries.
Sourcepub fn activate_strict<T: AsRef<str>>(&self, name: T) -> LadduResult<()>
pub fn activate_strict<T: AsRef<str>>(&self, name: T) -> LadduResult<()>
Activate an Amplitude by tag and return an error if it is missing.
Sourcepub fn activate_many<T: AsRef<str>>(&self, names: &[T])
pub fn activate_many<T: AsRef<str>>(&self, names: &[T])
Activate several Amplitudes by tag, skipping missing entries.
Sourcepub fn activate_many_strict<T: AsRef<str>>(
&self,
names: &[T],
) -> LadduResult<()>
pub fn activate_many_strict<T: AsRef<str>>( &self, names: &[T], ) -> LadduResult<()>
Activate several Amplitudes by tag and return an error if any are missing.
Sourcepub fn activate_all(&self)
pub fn activate_all(&self)
Activate all registered Amplitudes.
Sourcepub fn deactivate<T: AsRef<str>>(&self, name: T)
pub fn deactivate<T: AsRef<str>>(&self, name: T)
Deactivate an Amplitude by tag, skipping missing entries.
Sourcepub fn deactivate_strict<T: AsRef<str>>(&self, name: T) -> LadduResult<()>
pub fn deactivate_strict<T: AsRef<str>>(&self, name: T) -> LadduResult<()>
Deactivate an Amplitude by tag and return an error if it is missing.
Sourcepub fn deactivate_many<T: AsRef<str>>(&self, names: &[T])
pub fn deactivate_many<T: AsRef<str>>(&self, names: &[T])
Deactivate several Amplitudes by tag, skipping missing entries.
Sourcepub fn deactivate_many_strict<T: AsRef<str>>(
&self,
names: &[T],
) -> LadduResult<()>
pub fn deactivate_many_strict<T: AsRef<str>>( &self, names: &[T], ) -> LadduResult<()>
Deactivate several Amplitudes by tag and return an error if any are missing.
Sourcepub fn deactivate_all(&self)
pub fn deactivate_all(&self)
Deactivate all registered Amplitudes.
Sourcepub fn isolate<T: AsRef<str>>(&self, name: T)
pub fn isolate<T: AsRef<str>>(&self, name: T)
Isolate an Amplitude by tag (deactivate the rest), skipping missing entries.
Sourcepub fn isolate_strict<T: AsRef<str>>(&self, name: T) -> LadduResult<()>
pub fn isolate_strict<T: AsRef<str>>(&self, name: T) -> LadduResult<()>
Isolate an Amplitude by tag (deactivate the rest) and return an error if it is missing.
Sourcepub fn isolate_many<T: AsRef<str>>(&self, names: &[T])
pub fn isolate_many<T: AsRef<str>>(&self, names: &[T])
Isolate several Amplitudes by tag (deactivate the rest), skipping missing entries.
Sourcepub fn isolate_many_strict<T: AsRef<str>>(&self, names: &[T]) -> LadduResult<()>
pub fn isolate_many_strict<T: AsRef<str>>(&self, names: &[T]) -> LadduResult<()>
Isolate several Amplitudes by tag (deactivate the rest) and return an error if any are missing.
Sourcepub fn project_weights_local(
&self,
parameters: &[f64],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<Vec<f64>>
pub fn project_weights_local( &self, parameters: &[f64], mc_evaluator: Option<Evaluator>, ) -> LadduResult<Vec<f64>>
Project the stored Expression over the events in the Dataset stored by the
Evaluator with the given values for free parameters to obtain weights for each
Monte-Carlo event (non-MPI version).
§Notes
This method is not intended to be called in analyses but rather in writing methods
that have mpi-feature-gated versions. Most users will want to call NLL::project_weights instead.
Sourcepub fn project_weights(
&self,
parameters: &[f64],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<Vec<f64>>
pub fn project_weights( &self, parameters: &[f64], mc_evaluator: Option<Evaluator>, ) -> LadduResult<Vec<f64>>
Project the stored Expression over the events in the Dataset stored by the
Evaluator with the given values for free parameters to obtain weights for each
Monte-Carlo event. This method takes the real part of the given expression (discarding
the imaginary part entirely, which does not matter if expressions are coherent sums
wrapped in Expression::norm_sqr.
Event weights are determined by the following formula:
\text{weight}(\vec{p}; e) = \text{weight}(e) \mathcal{L}(e) / N_{\text{MC}}Note that $N_{\text{MC}}$ will always be the number of accepted Monte Carlo events,
regardless of the mc_evaluator.
Sourcepub fn project_weights_and_gradients_local(
&self,
parameters: &[f64],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<(Vec<f64>, Vec<DVector<f64>>)>
pub fn project_weights_and_gradients_local( &self, parameters: &[f64], mc_evaluator: Option<Evaluator>, ) -> LadduResult<(Vec<f64>, Vec<DVector<f64>>)>
Project the stored Expression over the events in the Dataset stored by the
Evaluator with the given values for free parameters to obtain weights and gradients of
those weights for each Monte-Carlo event (non-MPI version).
§Notes
This method is not intended to be called in analyses but rather in writing methods
that have mpi-feature-gated versions. Most users will want to call NLL::project_weights_and_gradients instead.
Sourcepub fn project_weights_and_gradients(
&self,
parameters: &[f64],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<(Vec<f64>, Vec<DVector<f64>>)>
pub fn project_weights_and_gradients( &self, parameters: &[f64], mc_evaluator: Option<Evaluator>, ) -> LadduResult<(Vec<f64>, Vec<DVector<f64>>)>
Project the stored Expression over the events in the Dataset stored by the
Evaluator with the given values for free parameters to obtain weights and gradients of
those weights for each Monte-Carlo event. This method takes the real part of the given
expression (discarding the imaginary part entirely, which does not matter if expressions
are coherent sums wrapped in Expression::norm_sqr.
Event weights are determined by the following formula:
\text{weight}(\vec{p}; e) = \text{weight}(e) \mathcal{L}(e) / N_{\text{MC}}Note that $N_{\text{MC}}$ will always be the number of accepted Monte Carlo events,
regardless of the mc_evaluator.
Sourcepub fn project_weights_subset_local<T: AsRef<str>>(
&self,
parameters: &[f64],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<Vec<f64>>
pub fn project_weights_subset_local<T: AsRef<str>>( &self, parameters: &[f64], names: &[T], mc_evaluator: Option<Evaluator>, ) -> LadduResult<Vec<f64>>
Project the model over one isolated amplitude subset in local execution, skipping missing amplitude tags.
Sourcepub fn project_weights_subset_local_strict<T: AsRef<str>>(
&self,
parameters: &[f64],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<Vec<f64>>
pub fn project_weights_subset_local_strict<T: AsRef<str>>( &self, parameters: &[f64], names: &[T], mc_evaluator: Option<Evaluator>, ) -> LadduResult<Vec<f64>>
Project the model over one isolated amplitude subset in local execution and return an error if any requested amplitude tag is missing.
Sourcepub fn project_weights_subset<T: AsRef<str>>(
&self,
parameters: &[f64],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<Vec<f64>>
pub fn project_weights_subset<T: AsRef<str>>( &self, parameters: &[f64], names: &[T], mc_evaluator: Option<Evaluator>, ) -> LadduResult<Vec<f64>>
Project the model over one isolated amplitude subset, skipping missing amplitude names.
Sourcepub fn project_weights_subset_strict<T: AsRef<str>>(
&self,
parameters: &[f64],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<Vec<f64>>
pub fn project_weights_subset_strict<T: AsRef<str>>( &self, parameters: &[f64], names: &[T], mc_evaluator: Option<Evaluator>, ) -> LadduResult<Vec<f64>>
Project the model over one isolated amplitude subset and return an error if any requested amplitude tag is missing.
Sourcepub fn project_weights_subsets_local<T: AsRef<str>>(
&self,
parameters: &[f64],
subsets: &[Vec<T>],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<Vec<Vec<f64>>>
pub fn project_weights_subsets_local<T: AsRef<str>>( &self, parameters: &[f64], subsets: &[Vec<T>], mc_evaluator: Option<Evaluator>, ) -> LadduResult<Vec<Vec<f64>>>
Project the model over multiple isolated amplitude subsets in local execution, skipping missing amplitude tags within each subset.
Sourcepub fn project_weights_subsets_local_strict<T: AsRef<str>>(
&self,
parameters: &[f64],
subsets: &[Vec<T>],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<Vec<Vec<f64>>>
pub fn project_weights_subsets_local_strict<T: AsRef<str>>( &self, parameters: &[f64], subsets: &[Vec<T>], mc_evaluator: Option<Evaluator>, ) -> LadduResult<Vec<Vec<f64>>>
Project the model over multiple isolated amplitude subsets in local execution and return an error if any requested amplitude tag is missing.
Sourcepub fn project_weights_subsets<T: AsRef<str>>(
&self,
parameters: &[f64],
subsets: &[Vec<T>],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<Vec<Vec<f64>>>
pub fn project_weights_subsets<T: AsRef<str>>( &self, parameters: &[f64], subsets: &[Vec<T>], mc_evaluator: Option<Evaluator>, ) -> LadduResult<Vec<Vec<f64>>>
Project the model over multiple isolated amplitude subsets, skipping missing amplitude tags within each subset.
Sourcepub fn project_weights_subsets_strict<T: AsRef<str>>(
&self,
parameters: &[f64],
subsets: &[Vec<T>],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<Vec<Vec<f64>>>
pub fn project_weights_subsets_strict<T: AsRef<str>>( &self, parameters: &[f64], subsets: &[Vec<T>], mc_evaluator: Option<Evaluator>, ) -> LadduResult<Vec<Vec<f64>>>
Project the model over multiple isolated amplitude subsets and return an error if any requested amplitude tag is missing.
Sourcepub fn project_weights_and_gradients_subset_local<T: AsRef<str>>(
&self,
parameters: &[f64],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<(Vec<f64>, Vec<DVector<f64>>)>
pub fn project_weights_and_gradients_subset_local<T: AsRef<str>>( &self, parameters: &[f64], names: &[T], mc_evaluator: Option<Evaluator>, ) -> LadduResult<(Vec<f64>, Vec<DVector<f64>>)>
Project the model and parameter gradients over one isolated amplitude subset in local execution, skipping missing amplitude tags.
Sourcepub fn project_weights_and_gradients_subset_local_strict<T: AsRef<str>>(
&self,
parameters: &[f64],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<(Vec<f64>, Vec<DVector<f64>>)>
pub fn project_weights_and_gradients_subset_local_strict<T: AsRef<str>>( &self, parameters: &[f64], names: &[T], mc_evaluator: Option<Evaluator>, ) -> LadduResult<(Vec<f64>, Vec<DVector<f64>>)>
Project the model and parameter gradients over one isolated amplitude subset in local execution and return an error if any requested amplitude tag is missing.
Sourcepub fn project_weights_and_gradients_subset<T: AsRef<str>>(
&self,
parameters: &[f64],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<(Vec<f64>, Vec<DVector<f64>>)>
pub fn project_weights_and_gradients_subset<T: AsRef<str>>( &self, parameters: &[f64], names: &[T], mc_evaluator: Option<Evaluator>, ) -> LadduResult<(Vec<f64>, Vec<DVector<f64>>)>
Project the model and parameter gradients over one isolated amplitude subset, skipping missing amplitude tags.
Sourcepub fn project_weights_and_gradients_subset_strict<T: AsRef<str>>(
&self,
parameters: &[f64],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> LadduResult<(Vec<f64>, Vec<DVector<f64>>)>
pub fn project_weights_and_gradients_subset_strict<T: AsRef<str>>( &self, parameters: &[f64], names: &[T], mc_evaluator: Option<Evaluator>, ) -> LadduResult<(Vec<f64>, Vec<DVector<f64>>)>
Project the model and parameter gradients over one isolated amplitude subset and return an error if any requested amplitude tag is missing.
Trait Implementations§
Source§impl CostFunction<MaybeThreadPool, LadduError> for NLL
impl CostFunction<MaybeThreadPool, LadduError> for NLL
Source§fn evaluate(
&self,
parameters: &DVector<f64>,
args: &MaybeThreadPool,
) -> LadduResult<f64>
fn evaluate( &self, parameters: &DVector<f64>, args: &MaybeThreadPool, ) -> LadduResult<f64>
x with the given arguments/user data. Read moreSource§impl Gradient<MaybeThreadPool, LadduError> for NLL
impl Gradient<MaybeThreadPool, LadduError> for NLL
Source§fn gradient(
&self,
parameters: &DVector<f64>,
args: &MaybeThreadPool,
) -> LadduResult<DVector<f64>>
fn gradient( &self, parameters: &DVector<f64>, args: &MaybeThreadPool, ) -> LadduResult<DVector<f64>>
x with the given arguments/user data. Read moreSource§fn evaluate_with_gradient(
&self,
x: &Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>,
args: &U,
) -> Result<(f64, Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>), E>
fn evaluate_with_gradient( &self, x: &Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, args: &U, ) -> Result<(f64, Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>), E>
x with the given
arguments/user data. Read moreSource§fn hessian(
&self,
x: &Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>,
args: &U,
) -> Result<Matrix<f64, Dyn, Dyn, VecStorage<f64, Dyn, Dyn>>, E>
fn hessian( &self, x: &Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, args: &U, ) -> Result<Matrix<f64, Dyn, Dyn, VecStorage<f64, Dyn, Dyn>>, E>
x with the given arguments/user data. Read moreSource§fn gradient_with_hessian(
&self,
x: &Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>,
args: &U,
) -> Result<(Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, Matrix<f64, Dyn, Dyn, VecStorage<f64, Dyn, Dyn>>), E>
fn gradient_with_hessian( &self, x: &Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, args: &U, ) -> Result<(Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, Matrix<f64, Dyn, Dyn, VecStorage<f64, Dyn, Dyn>>), E>
x with the given
arguments/user data. Read moreSource§fn evaluate_with_gradient_and_hessian(
&self,
x: &Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>,
args: &U,
) -> Result<(f64, Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, Matrix<f64, Dyn, Dyn, VecStorage<f64, Dyn, Dyn>>), E>
fn evaluate_with_gradient_and_hessian( &self, x: &Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, args: &U, ) -> Result<(f64, Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, Matrix<f64, Dyn, Dyn, VecStorage<f64, Dyn, Dyn>>), E>
x with the given
arguments/user data. Read moreSource§impl LikelihoodTerm for NLL
impl LikelihoodTerm for NLL
Source§fn evaluate(&self, parameters: &[f64]) -> LadduResult<f64>
fn evaluate(&self, parameters: &[f64]) -> LadduResult<f64>
Source§fn evaluate_gradient(&self, parameters: &[f64]) -> LadduResult<DVector<f64>>
fn evaluate_gradient(&self, parameters: &[f64]) -> LadduResult<DVector<f64>>
Source§fn fix_parameter(&self, name: &str, value: f64) -> LadduResult<()>
fn fix_parameter(&self, name: &str, value: f64) -> LadduResult<()>
Source§fn free_parameter(&self, name: &str) -> LadduResult<()>
fn free_parameter(&self, name: &str) -> LadduResult<()>
Source§fn rename_parameter(&self, old: &str, new: &str) -> LadduResult<()>
fn rename_parameter(&self, old: &str, new: &str) -> LadduResult<()>
Source§fn rename_parameters(
&self,
mapping: &HashMap<String, String>,
) -> LadduResult<()>
fn rename_parameters( &self, mapping: &HashMap<String, String>, ) -> LadduResult<()>
Source§fn parameter_map(&self) -> ParameterMap
fn parameter_map(&self) -> ParameterMap
Source§fn into_expression(self) -> LadduResult<LikelihoodExpression>where
Self: Sized + 'static,
fn into_expression(self) -> LadduResult<LikelihoodExpression>where
Self: Sized + 'static,
LikelihoodExpression. Read moreSource§impl LogDensity<MaybeThreadPool, LadduError> for NLL
impl LogDensity<MaybeThreadPool, LadduError> for NLL
Source§fn log_density(
&self,
parameters: &DVector<f64>,
args: &MaybeThreadPool,
) -> LadduResult<f64>
fn log_density( &self, parameters: &DVector<f64>, args: &MaybeThreadPool, ) -> LadduResult<f64>
x with the given arguments/user data. Read moreAuto Trait Implementations§
impl Freeze for NLL
impl !RefUnwindSafe for NLL
impl Send for NLL
impl Sync for NLL
impl Unpin for NLL
impl UnsafeUnpin for NLL
impl !UnwindSafe for NLL
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.