15#include "../../common/fims_vector.hpp"
16#include "../../common/def.hpp"
18namespace fims_distributions {
22template <
typename Type>
26 Type
lpdf =
static_cast<Type
>(0.0);
48 std::fill(this->
lpdf_vec.begin(), this->lpdf_vec.end(),
49 static_cast<Type
>(0));
51 static_cast<Type
>(0));
52 lpdf =
static_cast<Type
>(0);
55 if (n_x != n_expected) {
56 if (n_expected == 1) {
58 }
else if (n_x > n_expected) {
63 if (this->log_sd.
size() > 1 && n_x != this->log_sd.
size()) {
64 throw std::invalid_argument(
65 "NormalLPDF::Vector index out of bounds. The size of observed data "
66 "does not equal the size of the log_sd vector. The observed data "
67 "vector is of size " +
68 fims::to_string(n_x) +
" and the log_sd vector is of size " +
69 fims::to_string(this->log_sd.
size()));
72 for (
size_t i = 0; i < n_x; i++) {
80 fims_math::exp(
log_sd.get_force_scalar(i)),
true);
89 fims_math::exp(
log_sd.get_force_scalar(i)),
true);
98 fims_math::exp(
log_sd.get_force_scalar(i)));
102 fims_math::exp(
log_sd.get_force_scalar(i)));
107 fims_math::exp(
log_sd.get_force_scalar(i)));
122 vector<Type> normal_x = this->
x.to_tmb();
Definition fims_vector.hpp:27
size_type size() const
Returns the number of elements.
Definition fims_vector.hpp:273
Declares the DensityComponentBase class, which is the base class for all distribution functors.
#define FIMS_SIMULATE_F(F)
TMB macro that simulates data.
Definition interface.hpp:70
Base class for all module_name functors.
Definition density_components_base.hpp:152
fims::Vector< Type > lpdf_vec
Definition density_components_base.hpp:160
bool simulate_flag
Definition density_components_base.hpp:165
fims::Vector< Type > report_lpdf_vec
Definition density_components_base.hpp:162
size_t get_n_x()
Definition density_components_base.hpp:114
Type & get_observed(size_t i)
Definition density_components_base.hpp:55
std::vector< fims::Vector< Type > * > priors
Definition density_components_base.hpp:40
size_t get_n_expected()
Definition density_components_base.hpp:131
std::shared_ptr< fims_data_object::DataObject< Type > > observed_values
Definition density_components_base.hpp:32
fims::Vector< Type > * re
Definition density_components_base.hpp:35
std::string input_type
Definition density_components_base.hpp:28
fims::Vector< Type > x
Definition density_components_base.hpp:41
Type & get_expected(size_t i)
Definition density_components_base.hpp:98
Definition normal_lpdf.hpp:23
NormalLPDF()
Constructor.
Definition normal_lpdf.hpp:31
Type lpdf
Definition normal_lpdf.hpp:26
fims::Vector< Type > log_sd
Definition normal_lpdf.hpp:24
virtual ~NormalLPDF()
Destructor.
Definition normal_lpdf.hpp:35
virtual const Type evaluate()
Evaluates the normal probability density function.
Definition normal_lpdf.hpp:40