14#include "../../common/fims_vector.hpp"
15#include "../../common/def.hpp"
17namespace fims_distributions {
21template <
typename Type>
26 Type
lpdf =
static_cast<Type
>(0.0);
50 std::fill(this->
lpdf_vec.begin(), this->lpdf_vec.end(),
51 static_cast<Type
>(0));
53 static_cast<Type
>(0));
54 this->lpdf =
static_cast<Type
>(0);
58 if (n_x != n_expected) {
59 if (n_expected == 1) {
61 }
else if (n_x > n_expected) {
66 if (this->
log_sd.size() > 1 && n_x != this->
log_sd.size()) {
67 throw std::invalid_argument(
68 "LognormalLPDF::Vector index out of bounds. The size of observed "
69 "data does not equal the size of the log_sd vector. The observed "
70 "data vector is of size " +
71 fims::to_string(n_x) +
" and the log_sd vector is of size " +
72 fims::to_string(this->
log_sd.size()));
75 for (
size_t i = 0; i < n_x; i++) {
85 fims_math::exp(
log_sd.get_force_scalar(i)),
true) -
95 fims_math::exp(
log_sd.get_force_scalar(i)),
true);
99 fims_math::exp(
log_sd.get_force_scalar(i)),
true) -
112 fims_math::exp(
log_sd.get_force_scalar(i))));
115 (*this->
re)[i] = fims_math::exp(
117 fims_math::exp(
log_sd.get_force_scalar(i))));
120 (*(this->
priors[i]))[0] = fims_math::exp(
122 fims_math::exp(
log_sd.get_force_scalar(i))));
129 vector<Type> lognormal_x = this->
x.to_tmb();
Definition fims_vector.hpp:27
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 lognormal_lpdf.hpp:22
virtual ~LogNormalLPDF()
Destructor.
Definition lognormal_lpdf.hpp:37
Type lpdf
Definition lognormal_lpdf.hpp:26
LogNormalLPDF()
Constructor.
Definition lognormal_lpdf.hpp:33
fims::Vector< Type > log_sd
Definition lognormal_lpdf.hpp:24
virtual const Type evaluate()
Evaluates the lognormal probability density function.
Definition lognormal_lpdf.hpp:42