7 #ifndef SSMPACK_DISTRIBUTION_CATEGORICAL_HPP
8 #define SSMPACK_DISTRIBUTION_CATEGORICAL_HPP
15 namespace distribution {
24 using TParameterVar = arma::vec;
26 using TValueType =
unsigned int;
34 std::uniform_real_distribution<double> uniform_;
46 : param_(std::move(parameters)) {calcCDF(); calcMax();}
50 for (TValueType i = 0; i < max_; ++i)
73 void calcCDF() { cdf_ = arma::cumsum(param_); }
74 void calcMax() { max_ = param_.n_rows; }
80 #endif //SSMPACK_DISTRIBUTION_CATEGORICAL_HPP
Categorical & parameterize(const TParameterVar ¶m)
Change parameters of the distribution.
TValueType random()
Return a random variable from the distribution.
static Generator & get()
Returns a reference to singleton instance.
Categorical()
Default constructor .
Categorical (multinomial) distribution.
double likelihood(const TValueType &rv)
Return likelihood of the given random variable.
Categorical(TParameterVar parameters)
Constructor.