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 new(
model: &Model,
ds_data: &Arc<Dataset>,
ds_accmc: &Arc<Dataset>,
) -> Box<NLL>
pub fn new( model: &Model, ds_data: &Arc<Dataset>, ds_accmc: &Arc<Dataset>, ) -> Box<NLL>
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 activate_many<T>(&self, names: &[T]) -> Result<(), LadduError>
pub fn activate_many<T>(&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>(&self, name: T) -> Result<(), LadduError>
pub fn deactivate<T>(&self, name: T) -> Result<(), LadduError>
Dectivate an Amplitude by name.
Sourcepub fn deactivate_many<T>(&self, names: &[T]) -> Result<(), LadduError>
pub fn deactivate_many<T>(&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>(&self, name: T) -> Result<(), LadduError>
pub fn isolate<T>(&self, name: T) -> Result<(), LadduError>
Isolate an Amplitude by name (deactivate the rest).
Sourcepub fn isolate_many<T>(&self, names: &[T]) -> Result<(), LadduError>
pub fn isolate_many<T>(&self, names: &[T]) -> Result<(), LadduError>
Isolate several Amplitudes by name (deactivate the rest).
Sourcepub fn project_local(
&self,
parameters: &[f64],
mc_evaluator: Option<Evaluator>,
) -> Vec<f64>
pub fn project_local( &self, parameters: &[f64], mc_evaluator: Option<Evaluator>, ) -> Vec<f64>
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: &[f64],
mc_evaluator: Option<Evaluator>,
) -> Vec<f64>
pub fn project( &self, parameters: &[f64], mc_evaluator: Option<Evaluator>, ) -> Vec<f64>
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: &[f64],
mc_evaluator: Option<Evaluator>,
) -> (Vec<f64>, Vec<Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>>)
pub fn project_gradient_local( &self, parameters: &[f64], mc_evaluator: Option<Evaluator>, ) -> (Vec<f64>, Vec<Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>>)
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: &[f64],
mc_evaluator: Option<Evaluator>,
) -> (Vec<f64>, Vec<Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>>)
pub fn project_gradient( &self, parameters: &[f64], mc_evaluator: Option<Evaluator>, ) -> (Vec<f64>, Vec<Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>>)
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>(
&self,
parameters: &[f64],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> Result<Vec<f64>, LadduError>
pub fn project_with_local<T>( &self, parameters: &[f64], names: &[T], mc_evaluator: Option<Evaluator>, ) -> Result<Vec<f64>, 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>(
&self,
parameters: &[f64],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> Result<Vec<f64>, LadduError>
pub fn project_with<T>( &self, parameters: &[f64], names: &[T], mc_evaluator: Option<Evaluator>, ) -> Result<Vec<f64>, 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>(
&self,
parameters: &[f64],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> Result<(Vec<f64>, Vec<Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>>), LadduError>
pub fn project_gradient_with_local<T>( &self, parameters: &[f64], names: &[T], mc_evaluator: Option<Evaluator>, ) -> Result<(Vec<f64>, Vec<Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>>), 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>(
&self,
parameters: &[f64],
names: &[T],
mc_evaluator: Option<Evaluator>,
) -> Result<(Vec<f64>, Vec<Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>>), LadduError>
pub fn project_gradient_with<T>( &self, parameters: &[f64], names: &[T], mc_evaluator: Option<Evaluator>, ) -> Result<(Vec<f64>, Vec<Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>>), 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.
Source§impl NLL
impl NLL
Sourcepub fn minimize(
&self,
p0: &[f64],
bounds: Option<Vec<(f64, f64)>>,
options: Option<MinimizerOptions>,
) -> Result<Status, LadduError>
pub fn minimize( &self, p0: &[f64], bounds: Option<Vec<(f64, f64)>>, options: Option<MinimizerOptions>, ) -> Result<Status, LadduError>
Minimizes the negative log-likelihood using the L-BFGS-B algorithm (by default), a limited-memory quasi-Newton minimizer which supports bounded optimization.
Sourcepub fn mcmc<T>(
&self,
p0: T,
n_steps: usize,
options: Option<MCMCOptions>,
rng: Rng,
) -> Result<Ensemble, LadduError>
pub fn mcmc<T>( &self, p0: T, n_steps: usize, options: Option<MCMCOptions>, rng: Rng, ) -> Result<Ensemble, LadduError>
Sourcepub fn swarm(
&self,
swarm: Swarm,
options: Option<SwarmOptions>,
rng: Rng,
) -> Result<Swarm, LadduError>
pub fn swarm( &self, swarm: Swarm, options: Option<SwarmOptions>, rng: Rng, ) -> Result<Swarm, LadduError>
Perform Particle Swarm Optimization on this NLL.
Trait Implementations§
Source§impl Function<ThreadPool, LadduError> for NLL
impl Function<ThreadPool, LadduError> for NLL
Source§fn evaluate(
&self,
parameters: &[f64],
thread_pool: &mut ThreadPool,
) -> Result<f64, LadduError>
fn evaluate( &self, parameters: &[f64], thread_pool: &mut ThreadPool, ) -> Result<f64, LadduError>
x with the given arguments/user data. Read moreSource§fn gradient(
&self,
parameters: &[f64],
thread_pool: &mut ThreadPool,
) -> Result<Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, LadduError>
fn gradient( &self, parameters: &[f64], thread_pool: &mut ThreadPool, ) -> Result<Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, LadduError>
x with the given arguments/user data. Read moreSource§fn evaluate_bounded(
&self,
x: &[f64],
bounds: Option<&Vec<Bound>>,
user_data: &mut U,
) -> Result<f64, E>
fn evaluate_bounded( &self, x: &[f64], bounds: Option<&Vec<Bound>>, user_data: &mut U, ) -> Result<f64, E>
x with the given arguments/user data. This
function assumes x is an internal, unbounded vector, but performs a coordinate transform
to bound x when evaluating the function. Read moreSource§fn gradient_bounded(
&self,
x: &[f64],
bounds: Option<&Vec<Bound>>,
user_data: &mut U,
) -> Result<Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, E>
fn gradient_bounded( &self, x: &[f64], bounds: Option<&Vec<Bound>>, user_data: &mut U, ) -> Result<Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, E>
x with the given arguments/user data. This
function assumes x is an internal, unbounded vector, but performs a coordinate transform
to bound x when evaluating the function. Read moreSource§fn hessian(
&self,
x: &[f64],
user_data: &mut U,
) -> Result<Matrix<f64, Dyn, Dyn, VecStorage<f64, Dyn, Dyn>>, E>
fn hessian( &self, x: &[f64], user_data: &mut U, ) -> Result<Matrix<f64, Dyn, Dyn, VecStorage<f64, Dyn, Dyn>>, E>
x with the given arguments/user data. Read moreSource§fn hessian_bounded(
&self,
x: &[f64],
bounds: Option<&Vec<Bound>>,
user_data: &mut U,
) -> Result<Matrix<f64, Dyn, Dyn, VecStorage<f64, Dyn, Dyn>>, E>
fn hessian_bounded( &self, x: &[f64], bounds: Option<&Vec<Bound>>, user_data: &mut U, ) -> Result<Matrix<f64, Dyn, Dyn, VecStorage<f64, Dyn, Dyn>>, E>
x with the given arguments/user data. This
function assumes x is an internal, unbounded vector, but performs a coordinate transform
to bound x when evaluating the function. Read moreSource§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: &[f64]) -> f64
fn evaluate(&self, parameters: &[f64]) -> f64
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: &[f64],
) -> Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>
fn evaluate_gradient( &self, parameters: &[f64], ) -> Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>
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.
Auto 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.