1 #ifndef BARRY_MODEL_BONES_HPP
2 #define BARRY_MODEL_BONES_HPP 1
30 typename Data_Counter_Type = bool,
31 typename Data_Rule_Type = bool,
32 typename Data_Rule_Dyn_Type =
bool
127 std::function<std::vector<double>(
double *,
size_t k)>
141 const std::vector< double > & params,
147 const std::vector< double > & params,
152 const std::vector< double > & params,
202 std::vector<
double >
gen_key(const Array_Type & Array_);
214 Data_Counter_Type
data_ =
nullptr
237 Data_Rule_Dyn_Type
data_
253 size_t add_array(const Array_Type & Array_,
bool force_new = false);
269 const std::vector<
double> & params,
272 bool no_update_normconst = false
276 const std::vector<
double> & params,
277 const Array_Type & Array_,
280 bool no_update_normconst = false
284 const std::vector<
double> & params,
285 const std::vector<
double> & target_,
288 bool no_update_normconst = false
292 const std::vector<
double> & params,
293 const
double * target_,
296 bool no_update_normconst = false
300 const std::vector<
double> & params,
303 bool no_update_normconst = false
319 const std::vector< Array_Type > *
get_pset(
333 virtual
void print() const;
335 Array_Type
sample(const Array_Type & Array_, const std::vector<
double> & params = {});
336 Array_Type
sample(
const size_t &
i,
const std::vector<double> & params);
352 const Array_Type & Array_,
353 const std::vector< double > & params,
377 std::vector< std::
string >
colnames() const;
421 std::function<std::vector<
double>(
double*,
size_t)>
fun,
422 std::vector< std::
string > names
#define BARRY_NCORES_ARG(default)
Baseline class for binary arrays.
A counter function based on change statistics.
General framework for discrete exponential models. This class allows generating discrete exponential ...
size_t size_unique() const noexcept
std::vector< std::string > transform_model_term_names
const std::mt19937 * get_rengine() const
void update_normalizing_constants(const std::vector< double > ¶ms, BARRY_NCORES_ARG(=1), int i=-1)
Computes the normalizing constant for a given set of parameters.
std::vector< size_t > * get_stats_support_sizes_acc()
Accumulated number of vectors included in the support.
void update_pset_probs(const std::vector< double > ¶ms, BARRY_NCORES_ARG(=1), int i=-1)
Rules< Array_Type, Data_Rule_Dyn_Type > * rules_dyn
std::vector< size_t > pset_sizes
Number of vectors included in the support.
Rules< Array_Type, Data_Rule_Type > * rules
std::vector< double > * get_pset_stats()
Statistics of the support(s)
StatsCounter< Array_Type, Data_Counter_Type > counter_fun
size_t size() const noexcept
void add_counter(Counter< Array_Type, Data_Counter_Type > &counter)
Counters< Array_Type, Data_Counter_Type > * get_counters()
std::vector< std::vector< double > > stats_target
Target statistics of the model.
std::vector< double > pset_probs
Probabilities of the support(s)
Array_Type sample(const Array_Type &Array_, const std::vector< double > ¶ms={})
void add_rule_dyn(Rule< Array_Type, Data_Rule_Dyn_Type > &rule)
std::vector< double > stats_likelihood
std::vector< double > stats_support
Sufficient statistics of the model (support)
void store_psets() noexcept
double conditional_prob(const Array_Type &Array_, const std::vector< double > ¶ms, size_t i, size_t j)
Conditional probability ("Gibbs sampler")
Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type > & operator=(const Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type > &Model_)
std::vector< std::vector< double > > * get_stats_target()
Raw pointers to the support and target statistics.
std::vector< std::vector< Array_Type > > * get_pset_arrays()
Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type > * get_support_fun()
std::vector< double > gen_key(const Array_Type &Array_)
std::vector< size_t > arrays2support
size_t add_array(const Array_Type &Array_, bool force_new=false)
Adds an array to the support of not already included.
void add_hasher(Hasher_fun_type< Array_Type, Data_Counter_Type > fun_)
std::vector< std::string > colnames() const
double likelihood(const std::vector< double > ¶ms, const size_t &i, bool as_log=false, bool no_update_normconst=false)
std::vector< size_t > stats_support_sizes_acc
Accumulated number of vectors included in the support.
std::vector< double > * get_stats_support()
Sufficient statistics of the support(s)
void set_rules(Rules< Array_Type, Data_Rule_Type > *rules_)
size_t nrules() const noexcept
std::vector< size_t > * get_pset_locations()
const std::vector< double > & get_normalizing_constants() const
std::vector< size_t > stats_support_n_arrays
Number of arrays included per support.
void print_stats(size_t i) const
size_t nterms() const noexcept
double likelihood_total(const std::vector< double > ¶ms, bool as_log=false, BARRY_NCORES_ARG(=2), bool no_update_normconst=false)
Rules< Array_Type, Data_Rule_Type > * get_rules()
void set_counters(Counters< Array_Type, Data_Counter_Type > *counters_)
size_t support_size() const noexcept
size_t nrules_dyn() const noexcept
std::vector< std::vector< double > > params_last
Vector of the previously used parameters.
virtual void print() const
Prints information about the model.
std::vector< double > transform_model(double *data, size_t k)
Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type > support_fun
void set_rules_dyn(Rules< Array_Type, Data_Rule_Dyn_Type > *rules_)
std::vector< std::vector< Array_Type > > pset_arrays
Arrays of the support(s)
std::function< std::vector< double >double *, size_t k)> transform_model_fun
Transformation of the model.
std::vector< size_t > * get_arrays2support()
std::vector< double > * get_pset_probs()
std::vector< size_t > * get_pset_sizes()
MapVec_type< double, size_t > keys2support
Map of types of arrays to support sets.
std::vector< size_t > stats_support_sizes
Number of vectors included in the support.
std::vector< double > normalizing_constants
std::vector< size_t > * get_stats_support_sizes()
Number of vectors included in the support.
std::vector< double > pset_stats
Statistics of the support(s)
std::vector< size_t > pset_locations
Accumulated number of vectors included in the support.
std::vector< bool > first_calc_done
const std::vector< double > & get_likelihoods() const
void update_likelihoods(const std::vector< double > ¶ms,)
void set_transform_model(std::function< std::vector< double >(double *, size_t)> fun, std::vector< std::string > names)
Set the transform_model_fun object.
Counters< Array_Type, Data_Counter_Type > * counters
const std::vector< Array_Type > * get_pset(const size_t &i)
void set_rengine(std::mt19937 *rengine_, bool delete_=false)
void add_rule(Rule< Array_Type, Data_Rule_Type > &rule)
Rules< Array_Type, Data_Rule_Dyn_Type > * get_rules_dyn()
Rule for determining if a cell should be included in a sequence.
Vector of objects of class Rule.
Count stats for a single Array.
Compute the support of sufficient statistics.
Data_Type &&counter_ data(std::move(counter_.data))
Data_Type Counter_fun_type< Array_Type, Data_Type > init_fun_
Data_Type &&counter_ noexcept
Data_Type Counter_fun_type< Array_Type, Data_Type > Hasher_fun_type< Array_Type, Data_Type > Data_Type data_
std::unordered_map< std::vector< Ta >, Tb, vecHasher< Ta > > MapVec_type
std::function< bool(const Array_Type &, size_t, size_t, Data_Type &)> Rule_fun_type
std::function< std::vector< double >(const Array_Type &, Data_Type *)> Hasher_fun_type
Hasher function used by the counter.
std::function< double(const Array_Type &, size_t, size_t, Data_Type &)> Counter_fun_type
Counter and rule functions.