https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Gaussian Class Reference

A class used to generate a Gaussian likelihood of observing model predictions. More...

#include <Gaussian.h>

Inheritance diagram for Gaussian:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 Gaussian (const InputParameters &parameters)
 
virtual Real function (const std::vector< Real > &x) const override
 Return the probability density or mass function at vector x. More...
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
virtual const std::string & name () const
 
std::string typeAndName () const
 
std::string errorPrefix (const std::string &error_type) const
 
void callMooseError (std::string msg, const bool with_prefix) const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
const InputParametersparameters () const
 
MooseObjectName uniqueName () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &nm) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void mooseError (Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 
static Real function (const std::vector< Real > &exp, const std::vector< Real > &model, const Real &noise, const bool &log_likelihood)
 Return the probability density function. More...
 

Public Attributes

const ConsoleStream _console
 

Protected Member Functions

const ReporterNamegetReporterName (const std::string &param_name) const
 
virtual void addReporterDependencyHelper (const ReporterName &)
 
const T & getReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 

Protected Attributes

const bool _log_likelihood
 return log-likelihood or likelihood More...
 
const Real_noise
 Noise value. More...
 
std::vector< Real_exp_values
 Experimental data values. More...
 
const bool & _enabled
 
MooseApp_app
 
const std::string _type
 
const std::string _name
 
const InputParameters_pars
 
Factory_factory
 
ActionFactory_action_factory
 
const Parallel::Communicator & _communicator
 

Detailed Description

A class used to generate a Gaussian likelihood of observing model predictions.

Definition at line 18 of file Gaussian.h.

Constructor & Destructor Documentation

◆ Gaussian()

Gaussian::Gaussian ( const InputParameters parameters)

Definition at line 33 of file Gaussian.C.

35  ReporterInterface(this),
36  _log_likelihood(getParam<bool>("log_likelihood")),
37  _noise(getReporterValue<Real>("noise"))
38 {
39  if (isParamValid("exp_values") && isParamValid("file_name"))
40  paramError("exp_values", "exp_values and file_name both cannot be set at the same time.");
41  else if (isParamValid("file_name"))
42  {
43  MooseUtils::DelimitedFileReader reader(getParam<FileName>("file_name"));
44  reader.read();
45  if (isParamValid("file_column_name"))
46  _exp_values = reader.getData(getParam<std::string>("file_column_name"));
47  else
48  _exp_values = reader.getData(0);
49  }
50  else if (isParamValid("exp_values"))
51  _exp_values = getParam<std::vector<Real>>("exp_values");
52  else
53  mooseError("Either 'exp_values' or 'file_name' parameters must be specified to represent "
54  "experimental data.");
55 }
const Real & _noise
Noise value.
Definition: Gaussian.h:44
LikelihoodFunctionBase(const InputParameters &parameters)
bool isParamValid(const std::string &name) const
const bool _log_likelihood
return log-likelihood or likelihood
Definition: Gaussian.h:41
std::vector< Real > _exp_values
Experimental data values.
Definition: Gaussian.h:47
void paramError(const std::string &param, Args... args) const
ReporterInterface(const MooseObject *moose_object)
void mooseError(Args &&... args) const
const InputParameters & parameters() const

Member Function Documentation

◆ function() [1/2]

Real Gaussian::function ( const std::vector< Real > &  x) const
overridevirtual

Return the probability density or mass function at vector x.

Parameters
xThe input vector x

Implements LikelihoodFunctionBase.

Reimplemented in ExtremeValue, and TruncatedGaussian.

Definition at line 77 of file Gaussian.C.

78 {
79  return function(_exp_values, x, _noise, _log_likelihood);
80 }
const Real & _noise
Noise value.
Definition: Gaussian.h:44
const std::vector< double > x
const bool _log_likelihood
return log-likelihood or likelihood
Definition: Gaussian.h:41
std::vector< Real > _exp_values
Experimental data values.
Definition: Gaussian.h:47

◆ function() [2/2]

Real Gaussian::function ( const std::vector< Real > &  exp,
const std::vector< Real > &  model,
const Real noise,
const bool &  log_likelihood 
)
static

Return the probability density function.

Parameters
expThe experimental measurement
modelThe model prediction
noiseThe standard deviation
log_likelihoodBool to return the log likelihood value

Definition at line 58 of file Gaussian.C.

62 {
63  Real result = 0.0;
64  Real val1;
65  for (unsigned i = 0; i < exp.size(); ++i)
66  {
67  val1 = Normal::pdf(exp[i], model[i], noise);
68  val1 = std::log(val1);
69  result += val1;
70  }
71  if (!log_likelihood)
72  result = std::exp(result);
73  return result;
74 }
auto exp(const T &)
virtual Real pdf(const Real &x) const override
Definition: Normal.C:68
const PertinentGeochemicalSystem model(database, {"H2O", "H+", "HCO3-", "O2(aq)", "Ca++", ">(s)FeOH", "radius_neg1", "radius_neg1.5"}, {"Calcite"}, {}, {"Calcite_asdf"}, {"CH4(aq)"}, {">(s)FeOCa+"}, "O2(aq)", "e-")
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ validParams()

InputParameters Gaussian::validParams ( )
static

Definition at line 17 of file Gaussian.C.

Referenced by ExtremeValue::validParams(), and TruncatedGaussian::validParams().

18 {
20  params.addClassDescription(
21  "Gaussian likelihood function evaluating the model goodness against experiments.");
22  params.addParam<bool>("log_likelihood", true, "Compute log-likelihood or likelihood.");
24  "noise", "Experimental noise plus model deviations against experiments.");
25  params.addParam<FileName>("file_name", "Name of the CSV file with experimental values.");
26  params.addParam<std::string>(
27  "file_column_name", "Name of column in CSV file to use, by default first column is used.");
28  params.addParam<std::vector<Real>>(
29  "exp_values", "User-specified experimental values when CSV file is not provided.");
30  return params;
31 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)

Member Data Documentation

◆ _exp_values

std::vector<Real> Gaussian::_exp_values
protected

Experimental data values.

Definition at line 47 of file Gaussian.h.

Referenced by ExtremeValue::function(), TruncatedGaussian::function(), function(), and Gaussian().

◆ _log_likelihood

const bool Gaussian::_log_likelihood
protected

return log-likelihood or likelihood

Definition at line 41 of file Gaussian.h.

Referenced by ExtremeValue::function(), TruncatedGaussian::function(), and function().

◆ _noise

const Real& Gaussian::_noise
protected

Noise value.

Definition at line 44 of file Gaussian.h.

Referenced by ExtremeValue::function(), TruncatedGaussian::function(), and function().


The documentation for this class was generated from the following files: