pub struct NLL {
pub data_evaluator: Evaluator,
pub accmc_evaluator: Evaluator,
}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 minimize(
&self,
settings: MinimizationSettings<Self>,
) -> Result<MinimizationSummary, LadduError>
pub fn minimize( &self, settings: MinimizationSettings<Self>, ) -> Result<MinimizationSummary, LadduError>
Minimize the NLL with the algorithm given in the MinimizationSettings.
§Errors
This method may return an error if there was any problem constructing thread pools or evaluating the underlying model.
Sourcepub fn mcmc(
&self,
settings: MCMCSettings<Self>,
) -> Result<MCMCSummary, LadduError>
pub fn mcmc( &self, settings: MCMCSettings<Self>, ) -> Result<MCMCSummary, LadduError>
Run an MCMC sampling algorithm over the NLL with the given MCMCSettings.
§Errors
This method may return an error if there was any problem constructing thread pools or evaluating the underlying model.
Source§impl NLL
impl NLL
Sourcepub fn new(
model: &Model,
ds_data: &Arc<Dataset>,
ds_accmc: &Arc<Dataset>,
) -> Box<Self>
pub fn new( model: &Model, ds_data: &Arc<Dataset>, ds_accmc: &Arc<Dataset>, ) -> Box<Self>
Construct an NLL from a Model and two Datasets (data and Monte Carlo). This is the equivalent of the Model::load method,
but for two Datasets and a different method of evaluation.
Sourcepub fn to_stochastic(
&self,
batch_size: usize,
seed: Option<usize>,
) -> StochasticNLL
pub fn to_stochastic( &self, batch_size: usize, seed: Option<usize>, ) -> StochasticNLL
Create a new StochasticNLL from this NLL.
Sourcepub fn activate<T: AsRef<str>>(&self, name: T) -> Result<(), LadduError>
pub fn activate<T: AsRef<str>>(&self, name: T) -> Result<(), LadduError>
Activate an Amplitude by name.
Sourcepub fn activate_many<T: AsRef<str>>(
&self,
names: &[T],
) -> Result<(), LadduError>
pub fn activate_many<T: AsRef<str>>( &self, names: &[T], ) -> Result<(), LadduError>
Activate several Amplitudes by name.
Sourcepub fn activate_all(&self)
pub fn activate_all(&self)
Activate all registered Amplitudes.
Sourcepub fn deactivate<T: AsRef<str>>(&self, name: T) -> Result<(), LadduError>
pub fn deactivate<T: AsRef<str>>(&self, name: T) -> Result<(), LadduError>
Dectivate an Amplitude by name.
Sourcepub fn deactivate_many<T: AsRef<str>>(
&self,
names: &[T],
) -> Result<(), LadduError>
pub fn deactivate_many<T: AsRef<str>>( &self, names: &[T], ) -> Result<(), LadduError>
Deactivate several Amplitudes by name.
Sourcepub fn deactivate_all(&self)
pub fn deactivate_all(&self)
Deactivate all registered Amplitudes.
Sourcepub fn isolate<T: AsRef<str>>(&self, name: T) -> Result<(), LadduError>
pub fn isolate<T: AsRef<str>>(&self, name: T) -> Result<(), LadduError>
Isolate an Amplitude by name (deactivate the rest).
Sourcepub fn isolate_many<T: AsRef<str>>(&self, names: &[T]) -> Result<(), LadduError>
pub fn isolate_many<T: AsRef<str>>(&self, names: &[T]) -> Result<(), LadduError>
Isolate several Amplitudes by name (deactivate the rest).
Sourcepub fn project_local(
&self,
parameters: &[Float],
mc_evaluator: Option<Evaluator>,
) -> Vec<Float> ⓘ
pub fn project_local( &self, parameters: &[Float], mc_evaluator: Option<Evaluator>, ) -> Vec<Float> ⓘ
Project the stored Model 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 instead.
Sourcepub fn project(
&self,
parameters: &[Float],
mc_evaluator: Option<Evaluator>,
) -> Vec<Float> ⓘ
pub fn project( &self, parameters: &[Float], mc_evaluator: Option<Evaluator>, ) -> Vec<Float> ⓘ
Project the stored Model 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_gradient_local(
&self,
parameters: &[Float],
mc_evaluator: Option<Evaluator>,
) -> (Vec<Float>, Vec<DVector<Float>>)
pub fn project_gradient_local( &self, parameters: &[Float], mc_evaluator: Option<Evaluator>, ) -> (Vec<Float>, Vec<DVector<Float>>)
Project the stored Model 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_gradient instead.
Sourcepub fn project_gradient(
&self,
parameters: &[Float],
mc_evaluator: Option<Evaluator>,
) -> (Vec<Float>, Vec<DVector<Float>>)
pub fn project_gradient( &self, parameters: &[Float], mc_evaluator: Option<Evaluator>, ) -> (Vec<Float>, Vec<DVector<Float>>)
Project the stored Model 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_with_local<T: AsRef<str>>(
&self,
parameters: &[Float],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> Result<Vec<Float>, LadduError>
pub fn project_with_local<T: AsRef<str>>( &self, parameters: &[Float], names: &[T], mc_evaluator: Option<Evaluator>, ) -> Result<Vec<Float>, LadduError>
Project the stored Model 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 differs from the standard
NLL::project in that it first isolates the selected Amplitudes
by name, but returns the NLL to its prior state after calculation (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_with instead.
Sourcepub fn project_with<T: AsRef<str>>(
&self,
parameters: &[Float],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> Result<Vec<Float>, LadduError>
pub fn project_with<T: AsRef<str>>( &self, parameters: &[Float], names: &[T], mc_evaluator: Option<Evaluator>, ) -> Result<Vec<Float>, LadduError>
Project the stored Model 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 differs from the standard
NLL::project in that it first isolates the selected Amplitudes
by name, but returns the NLL to its prior state after calculation.
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_gradient_with_local<T: AsRef<str>>(
&self,
parameters: &[Float],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> Result<(Vec<Float>, Vec<DVector<Float>>), LadduError>
pub fn project_gradient_with_local<T: AsRef<str>>( &self, parameters: &[Float], names: &[T], mc_evaluator: Option<Evaluator>, ) -> Result<(Vec<Float>, Vec<DVector<Float>>), LadduError>
Project the stored Model 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 differs from the standard
NLL::project_gradient in that it first isolates the selected Amplitudes
by name, but returns the NLL to its prior state after calculation (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_with instead.
Sourcepub fn project_gradient_with<T: AsRef<str>>(
&self,
parameters: &[Float],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> Result<(Vec<Float>, Vec<DVector<Float>>), LadduError>
pub fn project_gradient_with<T: AsRef<str>>( &self, parameters: &[Float], names: &[T], mc_evaluator: Option<Evaluator>, ) -> Result<(Vec<Float>, Vec<DVector<Float>>), LadduError>
Project the stored Model 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 differs from the standard NLL::project_gradient in that it first
isolates the selected Amplitudes by name, but returns
the NLL to its prior state after calculation.
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.
Trait Implementations§
Source§impl CostFunction<MaybeThreadPool, LadduError> for NLL
impl CostFunction<MaybeThreadPool, LadduError> for NLL
Source§fn evaluate(
&self,
parameters: &DVector<Float>,
args: &MaybeThreadPool,
) -> Result<Float, LadduError>
fn evaluate( &self, parameters: &DVector<Float>, args: &MaybeThreadPool, ) -> Result<Float, LadduError>
x with the given arguments/user data. Read moreSource§impl Gradient<MaybeThreadPool, LadduError> for NLL
impl Gradient<MaybeThreadPool, LadduError> for NLL
Source§impl LikelihoodTerm for NLL
impl LikelihoodTerm for NLL
Source§fn parameters(&self) -> Vec<String>
fn parameters(&self) -> Vec<String>
Get the list of parameter names in the order they appear in the NLL::evaluate
method.
Source§fn evaluate(&self, parameters: &[Float]) -> Float
fn evaluate(&self, parameters: &[Float]) -> Float
Evaluate the stored Model over the events in the Dataset stored by the
Evaluator with the given values for free parameters. 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. The
result is given by the following formula:
NLL(\vec{p}) = -2 \left(\sum_{e \in \text{Data}} \text{weight}(e) \ln(\mathcal{L}(e)) - \frac{1}{N_{\text{MC}_A}} \sum_{e \in \text{MC}_A} \text{weight}(e) \mathcal{L}(e) \right)Source§fn evaluate_gradient(&self, parameters: &[Float]) -> DVector<Float>
fn evaluate_gradient(&self, parameters: &[Float]) -> DVector<Float>
Evaluate the gradient of the stored Model over the events in the Dataset
stored by the Evaluator with the given values for free parameters. 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.
Source§impl LogDensity<MaybeThreadPool, LadduError> for NLL
impl LogDensity<MaybeThreadPool, LadduError> for NLL
Source§fn log_density(
&self,
parameters: &DVector<Float>,
args: &MaybeThreadPool,
) -> Result<Float, LadduError>
fn log_density( &self, parameters: &DVector<Float>, args: &MaybeThreadPool, ) -> Result<Float, LadduError>
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 !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.