barry: Your go-to motif accountant  0.0-1
Full enumeration of sample space and fast count of sufficient statistics for binary arrays
Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type > Class Template Reference

General framework for discrete exponential models. This class allows generating discrete exponential models in the form of a linear exponential model: More...

#include <model-bones.hpp>

Collaboration diagram for Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >:

Public Member Functions

void update_normalizing_constants (const std::vector< double > &params, BARRY_NCORES_ARG(=1), int i=-1)
 Computes the normalizing constant for a given set of parameters. More...
 
void update_likelihoods (const std::vector< double > &params,)
 
void update_pset_probs (const std::vector< double > &params, BARRY_NCORES_ARG(=1), int i=-1)
 
void set_rengine (std::mt19937 *rengine_, bool delete_=false)
 
void set_seed (size_t s)
 
 Model ()
 
 Model (size_t size_)
 
 Model (const Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type > &Model_)
 
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_)
 
virtual ~Model ()
 
void store_psets () noexcept
 
std::vector< double > gen_key (const Array_Type &Array_)
 
size_t add_array (const Array_Type &Array_, bool force_new=false)
 Adds an array to the support of not already included. More...
 
void print_stats (size_t i) const
 
virtual void print () const
 Prints information about the model. More...
 
Array_Type sample (const Array_Type &Array_, const std::vector< double > &params={})
 
Array_Type sample (const size_t &i, const std::vector< double > &params)
 
double conditional_prob (const Array_Type &Array_, const std::vector< double > &params, size_t i, size_t j)
 Conditional probability ("Gibbs sampler") More...
 
const std::mt19937 * get_rengine () const
 
Counters< Array_Type, Data_Counter_Type > * get_counters ()
 
Rules< Array_Type, Data_Rule_Type > * get_rules ()
 
Rules< Array_Type, Data_Rule_Dyn_Type > * get_rules_dyn ()
 
Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type > * get_support_fun ()
 
Wrappers for the <tt>Counters</tt> member.

These will add counters to the model, which are shared by the support and the actual counter function.

void add_counter (Counter< Array_Type, Data_Counter_Type > &counter)
 
void add_counter (Counter_fun_type< Array_Type, Data_Counter_Type > count_fun_, Counter_fun_type< Array_Type, Data_Counter_Type > init_fun_=nullptr, Data_Counter_Type data_=nullptr)
 
void set_counters (Counters< Array_Type, Data_Counter_Type > *counters_)
 
void add_hasher (Hasher_fun_type< Array_Type, Data_Counter_Type > fun_)
 
Wrappers for the <tt>Rules</tt> member.

These will add rules to the model, which are shared by the support and the actual counter function.

void add_rule (Rule< Array_Type, Data_Rule_Type > &rule)
 
void add_rule (Rule_fun_type< Array_Type, Data_Rule_Type > count_fun_, Data_Rule_Type data_)
 
void set_rules (Rules< Array_Type, Data_Rule_Type > *rules_)
 
void add_rule_dyn (Rule< Array_Type, Data_Rule_Dyn_Type > &rule)
 
void add_rule_dyn (Rule_fun_type< Array_Type, Data_Rule_Dyn_Type > count_fun_, Data_Rule_Dyn_Type data_)
 
void set_rules_dyn (Rules< Array_Type, Data_Rule_Dyn_Type > *rules_)
 
Likelihood functions.

Calculation of likelihood functions is done reusing normalizing constants. Before recalculating the normalizing constant, the function checks whether params matches the last set vector of parameters used to compute it.

Parameters
paramsVector of parameters
as_logWhen true, the function returns the log-likelihood.
double likelihood (const std::vector< double > &params, const size_t &i, bool as_log=false, bool no_update_normconst=false)
 
double likelihood (const std::vector< double > &params, const Array_Type &Array_, int i=-1, bool as_log=false, bool no_update_normconst=false)
 
double likelihood (const std::vector< double > &params, const std::vector< double > &target_, const size_t &i, bool as_log=false, bool no_update_normconst=false)
 
double likelihood (const std::vector< double > &params, const double *target_, const size_t &i, bool as_log=false, bool no_update_normconst=false)
 
double likelihood_total (const std::vector< double > &params, bool as_log=false, BARRY_NCORES_ARG(=2), bool no_update_normconst=false)
 
Extract elements by index
Parameters
iIndex relative to the array in the model.
paramsA new vector of model parameters to compute the normalizing constant.
as_logWhen true returns the logged version of the normalizing constant.
const std::vector< double > & get_normalizing_constants () const
 
const std::vector< double > & get_likelihoods () const
 
const std::vector< Array_Type > * get_pset (const size_t &i)
 
const double * get_pset_stats (const size_t &i)
 
Size of the model

Number of different supports included in the model

This will return the size of stats_target.

Returns
size() returns the number of arrays in the model.
size_unique() returns the number of unique arrays (according to the hasher) in the model.
nterms() returns the number of terms in the model.
size_t size () const noexcept
 
size_t size_unique () const noexcept
 
size_t nterms () const noexcept
 
size_t nrules () const noexcept
 
size_t nrules_dyn () const noexcept
 
size_t support_size () const noexcept
 
std::vector< std::string > colnames () const
 
std::vector< std::vector< double > > * get_stats_target ()
 Raw pointers to the support and target statistics. More...
 
std::vector< double > * get_stats_support ()
 Sufficient statistics of the support(s) More...
 
std::vector< size_t > * get_stats_support_sizes ()
 Number of vectors included in the support. More...
 
std::vector< size_t > * get_stats_support_sizes_acc ()
 Accumulated number of vectors included in the support. More...
 
std::vector< size_t > * get_arrays2support ()
 
std::vector< std::vector< Array_Type > > * get_pset_arrays ()
 
std::vector< double > * get_pset_stats ()
 Statistics of the support(s) More...
 
std::vector< double > * get_pset_probs ()
 
std::vector< size_t > * get_pset_sizes ()
 
std::vector< size_t > * get_pset_locations ()
 
void set_transform_model (std::function< std::vector< double >(double *, size_t)> fun, std::vector< std::string > names)
 Set the transform_model_fun object. More...
 
std::vector< double > transform_model (double *data, size_t k)
 

Protected Attributes

MapVec_type< double, size_t > keys2support
 Map of types of arrays to support sets. More...
 
std::vector< std::vector< double > > params_last
 Vector of the previously used parameters. More...
 
std::vector< double > normalizing_constants
 
std::vector< bool > first_calc_done
 
bool delete_counters = false
 
bool delete_rules = false
 
bool delete_rules_dyn = false
 
std::function< std::vector< double >double *, size_t k)> transform_model_fun = nullptr
 Transformation of the model. More...
 
std::vector< std::string > transform_model_term_names
 
Random number generation

Random number generation

std::mt19937 * rengine = nullptr
 
bool delete_rengine = false
 
Information about the arrays used in the model

stats_target holds the observed sufficient statistics for each array in the dataset. array_frequency contains the frequency with which each of the target stats_target (arrays) shows in the support. array2support maps array indices (0, 1, ...) to the corresponding support.

Each vector of stats_support has the data stored in a row-wise order, with each row starting with the weights, e.g., in a model with k terms the first k + 1 elements of stats_support would be:

  • weights
  • term 1
  • term 2
  • ...
  • term k
std::vector< double > stats_support
 Sufficient statistics of the model (support) More...
 
std::vector< size_t > stats_support_sizes
 Number of vectors included in the support. More...
 
std::vector< size_t > stats_support_sizes_acc
 Accumulated number of vectors included in the support. More...
 
std::vector< size_t > stats_support_n_arrays
 Number of arrays included per support. More...
 
std::vector< std::vector< double > > stats_target
 Target statistics of the model. More...
 
std::vector< double > stats_likelihood
 
std::vector< size_t > arrays2support
 
Container space for the powerset (and its sufficient stats_target)

This is useful in the case of using simulations or evaluating functions that need to account for the full set of states.

bool with_pset = false
 
std::vector< std::vector< Array_Type > > pset_arrays
 Arrays of the support(s) More...
 
std::vector< double > pset_stats
 Statistics of the support(s) More...
 
std::vector< double > pset_probs
 Probabilities of the support(s) More...
 
std::vector< size_t > pset_sizes
 Number of vectors included in the support. More...
 
std::vector< size_t > pset_locations
 Accumulated number of vectors included in the support. More...
 
Functions to compute statistics

Arguments are recycled to save memory and computation.

Counters< Array_Type, Data_Counter_Type > * counters
 
Rules< Array_Type, Data_Rule_Type > * rules
 
Rules< Array_Type, Data_Rule_Dyn_Type > * rules_dyn
 
Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type > support_fun
 
StatsCounter< Array_Type, Data_Counter_Type > counter_fun
 

Detailed Description

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
class Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >

General framework for discrete exponential models. This class allows generating discrete exponential models in the form of a linear exponential model:

\[ \frac{ \exp{\left(\theta^{\mbox{t}}c(A)\right)} }{ \sum_{A'\in \mathcal{A}}\exp{\left(\theta^{\mbox{t}}c(A')\right)} } \]

This implementation aims to reduce the number of times that the support needs to be computed. Models included here use more than a single array, and thus allow the function to recycle support sets as needed. For example, if we are looking at directed graphs all of the same size and without vertex level features, i.e. a model that only counts edges, triangles, etc. then the support needs to be fully computed only once.

Template Parameters
Array_TypeClass of BArray object.
Data_Counter_TypeAny type.
Data_Rule_TypeAny type.

Definition at line 34 of file model-bones.hpp.

Constructor & Destructor Documentation

◆ Model() [1/3]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::Model
inline

Definition at line 309 of file model-meat.hpp.

◆ Model() [2/3]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::Model ( size_t  size_)
inline

Definition at line 347 of file model-meat.hpp.

◆ Model() [3/3]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::Model ( const Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type > &  Model_)
inline

Definition at line 389 of file model-meat.hpp.

◆ ~Model()

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
virtual Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::~Model ( )
inlinevirtual

Definition at line 187 of file model-bones.hpp.

Member Function Documentation

◆ add_array()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
size_t Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::add_array ( const Array_Type &  Array_,
bool  force_new = false 
)
inline

Adds an array to the support of not already included.

Parameters
Array_array to be added
force_newIf false, it will use keygen to obtain a double vector and create a hash of it. If the hash has been computed earlier, the support is recycled.
Returns
The number of the array.

When computing with the powerset, we need to grow the corresponding vectors on the fly

Definition at line 633 of file model-meat.hpp.

◆ add_counter() [1/2]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::add_counter ( Counter< Array_Type, Data_Counter_Type > &  counter)
inline

Definition at line 508 of file model-meat.hpp.

◆ add_counter() [2/2]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::add_counter ( Counter_fun_type< Array_Type, Data_Counter_Type >  count_fun_,
Counter_fun_type< Array_Type, Data_Counter_Type >  init_fun_ = nullptr,
Data_Counter_Type  data_ = nullptr 
)
inline

Definition at line 517 of file model-meat.hpp.

◆ add_hasher()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::add_hasher ( Hasher_fun_type< Array_Type, Data_Counter_Type >  fun_)
inline

Definition at line 552 of file model-meat.hpp.

◆ add_rule() [1/2]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::add_rule ( Rule< Array_Type, Data_Rule_Type > &  rule)
inline

Definition at line 563 of file model-meat.hpp.

◆ add_rule() [2/2]

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::add_rule ( Rule_fun_type< Array_Type, Data_Rule_Type >  count_fun_,
Data_Rule_Type  data_ 
)

◆ add_rule_dyn() [1/2]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::add_rule_dyn ( Rule< Array_Type, Data_Rule_Dyn_Type > &  rule)
inline

Definition at line 591 of file model-meat.hpp.

◆ add_rule_dyn() [2/2]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::add_rule_dyn ( Rule_fun_type< Array_Type, Data_Rule_Dyn_Type >  count_fun_,
Data_Rule_Dyn_Type  data_ 
)
inline

Definition at line 600 of file model-meat.hpp.

◆ colnames()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
std::vector< std::string > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::colnames
inline

Definition at line 1389 of file model-meat.hpp.

◆ conditional_prob()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
double Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::conditional_prob ( const Array_Type &  Array_,
const std::vector< double > &  params,
size_t  i,
size_t  j 
)
inline

Conditional probability ("Gibbs sampler")

Computes the conditional probability of observing P{Y(i,j) = | Y^C, theta}, i.e., the probability of observing the entry Y(i,j) equal to one given the rest of the array.

Parameters
Array_Array to check
paramsVector of parameters
iRow entry
jColumn entry
Returns
double The conditional probability

Definition at line 1689 of file model-meat.hpp.

◆ gen_key()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
std::vector< double > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::gen_key ( const Array_Type &  Array_)
inline

Definition at line 501 of file model-meat.hpp.

◆ get_arrays2support()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
std::vector< size_t > * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_arrays2support
inline

Definition at line 1778 of file model-meat.hpp.

◆ get_counters()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
Counters< Array_Type, Data_Counter_Type > * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_counters
inline

Definition at line 1727 of file model-meat.hpp.

◆ get_likelihoods()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
const std::vector< double > & Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_likelihoods
inline

Definition at line 1178 of file model-meat.hpp.

◆ get_normalizing_constants()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
const std::vector< double > & Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_normalizing_constants
inline

Definition at line 1165 of file model-meat.hpp.

◆ get_pset()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
const std::vector< Array_Type > * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_pset ( const size_t &  i)
inline

Definition at line 1186 of file model-meat.hpp.

◆ get_pset_arrays()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
std::vector< std::vector< Array_Type > > * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_pset_arrays
inline

Definition at line 1785 of file model-meat.hpp.

◆ get_pset_locations()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
std::vector< size_t > * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_pset_locations
inline

Definition at line 1823 of file model-meat.hpp.

◆ get_pset_probs()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
std::vector< double > * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_pset_probs
inline

Definition at line 1802 of file model-meat.hpp.

◆ get_pset_sizes()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
std::vector< size_t > * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_pset_sizes
inline

Definition at line 1812 of file model-meat.hpp.

◆ get_pset_stats() [1/2]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
std::vector< double > * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_pset_stats
inline

Statistics of the support(s)

Definition at line 1791 of file model-meat.hpp.

◆ get_pset_stats() [2/2]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
const double * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_pset_stats ( const size_t &  i)
inline

Definition at line 1200 of file model-meat.hpp.

◆ get_rengine()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
const std::mt19937 * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_rengine
inline

Definition at line 1722 of file model-meat.hpp.

◆ get_rules()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
Rules< Array_Type, Data_Rule_Type > * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_rules
inline

Definition at line 1732 of file model-meat.hpp.

◆ get_rules_dyn()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
Rules< Array_Type, Data_Rule_Dyn_Type > * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_rules_dyn
inline

Definition at line 1737 of file model-meat.hpp.

◆ get_stats_support()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
std::vector< double > * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_stats_support
inline

Sufficient statistics of the support(s)

Definition at line 1755 of file model-meat.hpp.

◆ get_stats_support_sizes()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
std::vector< size_t > * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_stats_support_sizes
inline

Number of vectors included in the support.

Definition at line 1763 of file model-meat.hpp.

◆ get_stats_support_sizes_acc()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
std::vector< size_t > * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_stats_support_sizes_acc
inline

Accumulated number of vectors included in the support.

Definition at line 1771 of file model-meat.hpp.

◆ get_stats_target()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
std::vector< std::vector< double > > * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_stats_target
inline

Raw pointers to the support and target statistics.

The support of the model is stored as a vector of vector<double>. Each element of it contains the support for an specific type of array included. It represents an array of size (k + 1) x n unique elements, with the data stored by-row. The last element of each entry corresponds to the weights, i.e., the frequency with which such sufficient statistics are observed in the support.

Definition at line 1748 of file model-meat.hpp.

◆ get_support_fun()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type > * Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_support_fun
inline

Definition at line 1743 of file model-meat.hpp.

◆ likelihood() [1/4]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
double Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::likelihood ( const std::vector< double > &  params,
const Array_Type &  Array_,
int  i = -1,
bool  as_log = false,
bool  no_update_normconst = false 
)
inline

Definition at line 857 of file model-meat.hpp.

◆ likelihood() [2/4]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
double Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::likelihood ( const std::vector< double > &  params,
const double *  target_,
const size_t &  i,
bool  as_log = false,
bool  no_update_normconst = false 
)
inline

Definition at line 1007 of file model-meat.hpp.

◆ likelihood() [3/4]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
double Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::likelihood ( const std::vector< double > &  params,
const size_t &  i,
bool  as_log = false,
bool  no_update_normconst = false 
)
inline

Definition at line 810 of file model-meat.hpp.

◆ likelihood() [4/4]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
double Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::likelihood ( const std::vector< double > &  params,
const std::vector< double > &  target_,
const size_t &  i,
bool  as_log = false,
bool  no_update_normconst = false 
)
inline

Definition at line 941 of file model-meat.hpp.

◆ likelihood_total()

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
double Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::likelihood_total ( const std::vector< double > &  params,
bool  as_log = false,
BARRY_NCORES_ARG(=2)  ,
bool  no_update_normconst = false 
)
inline

Definition at line 1079 of file model-meat.hpp.

◆ nrules()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
size_t Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::nrules
inlinenoexcept

Definition at line 1359 of file model-meat.hpp.

◆ nrules_dyn()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
size_t Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::nrules_dyn
inlinenoexcept

Definition at line 1367 of file model-meat.hpp.

◆ nterms()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
size_t Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::nterms
inlinenoexcept

Definition at line 1348 of file model-meat.hpp.

◆ operator=()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type > & 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_)
inline

Definition at line 439 of file model-meat.hpp.

◆ print()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::print
inlinevirtual

Prints information about the model.

Definition at line 1252 of file model-meat.hpp.

◆ print_stats()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::print_stats ( size_t  i) const
inline

Definition at line 1212 of file model-meat.hpp.

◆ sample() [1/2]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
Array_Type Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::sample ( const Array_Type &  Array_,
const std::vector< double > &  params = {} 
)
inline

When computing with the powerset, we need to grow the corresponding vectors on the fly

Definition at line 1476 of file model-meat.hpp.

◆ sample() [2/2]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
Array_Type Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::sample ( const size_t &  i,
const std::vector< double > &  params 
)
inline

Definition at line 1406 of file model-meat.hpp.

◆ set_counters()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::set_counters ( Counters< Array_Type, Data_Counter_Type > *  counters_)
inline

Definition at line 534 of file model-meat.hpp.

◆ set_rengine()

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::set_rengine ( std::mt19937 *  rengine_,
bool  delete_ = false 
)
inline

Definition at line 157 of file model-bones.hpp.

◆ set_rules()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::set_rules ( Rules< Array_Type, Data_Rule_Type > *  rules_)
inline

Definition at line 573 of file model-meat.hpp.

◆ set_rules_dyn()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::set_rules_dyn ( Rules< Array_Type, Data_Rule_Dyn_Type > *  rules_)
inline

Definition at line 615 of file model-meat.hpp.

◆ set_seed()

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::set_seed ( size_t  s)
inline

Definition at line 167 of file model-bones.hpp.

◆ set_transform_model()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::set_transform_model ( std::function< std::vector< double >(double *, size_t)>  fun,
std::vector< std::string >  names 
)
inline

Set the transform_model_fun object.

The transform_model function is used to transform the data

Parameters
data
target
n_arrays
arrays2support

Definition at line 1835 of file model-meat.hpp.

◆ size()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
size_t Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::size
inlinenoexcept

Definition at line 1331 of file model-meat.hpp.

◆ size_unique()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
size_t Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::size_unique
inlinenoexcept

Definition at line 1339 of file model-meat.hpp.

◆ store_psets()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::store_psets
inlinenoexcept

Definition at line 495 of file model-meat.hpp.

◆ support_size()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
size_t Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::support_size
inlinenoexcept

Definition at line 1375 of file model-meat.hpp.

◆ transform_model()

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector<double> Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::transform_model ( double *  data,
size_t  k 
)

◆ update_likelihoods()

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::update_likelihoods ( const std::vector< double > &  params)
inline

Definition at line 186 of file model-meat.hpp.

◆ update_normalizing_constants()

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::update_normalizing_constants ( const std::vector< double > &  params,
BARRY_NCORES_ARG(=1)  ,
int  i = -1 
)
inline

Computes the normalizing constant for a given set of parameters.

This function will compute the normalizing constant for a given set of parameters. It will also update the normalizing_constants member variable.

Definition at line 136 of file model-meat.hpp.

◆ update_pset_probs()

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
void Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::update_pset_probs ( const std::vector< double > &  params,
BARRY_NCORES_ARG(=1)  ,
int  i = -1 
)
inline

Definition at line 225 of file model-meat.hpp.

Member Data Documentation

◆ arrays2support

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< size_t > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::arrays2support
protected

Definition at line 68 of file model-bones.hpp.

◆ counter_fun

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
StatsCounter<Array_Type,Data_Counter_Type> Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::counter_fun
protected

Definition at line 100 of file model-bones.hpp.

◆ counters

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
Counters<Array_Type,Data_Counter_Type>* Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::counters
protected

Definition at line 96 of file model-bones.hpp.

◆ delete_counters

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
bool Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::delete_counters = false
protected

Definition at line 108 of file model-bones.hpp.

◆ delete_rengine

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
bool Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::delete_rengine = false
protected

Definition at line 43 of file model-bones.hpp.

◆ delete_rules

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
bool Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::delete_rules = false
protected

Definition at line 109 of file model-bones.hpp.

◆ delete_rules_dyn

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
bool Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::delete_rules_dyn = false
protected

Definition at line 110 of file model-bones.hpp.

◆ first_calc_done

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< bool > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::first_calc_done
protected

Definition at line 106 of file model-bones.hpp.

◆ keys2support

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
MapVec_type< double, size_t > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::keys2support
protected

Map of types of arrays to support sets.

This is of the same length as the vector stats_target.

Definition at line 75 of file model-bones.hpp.

◆ normalizing_constants

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< double > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::normalizing_constants
protected

Definition at line 105 of file model-bones.hpp.

◆ params_last

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< std::vector<double> > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::params_last
protected

Vector of the previously used parameters.

Definition at line 104 of file model-bones.hpp.

◆ pset_arrays

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< std::vector< Array_Type > > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::pset_arrays
protected

Arrays of the support(s)

Definition at line 84 of file model-bones.hpp.

◆ pset_locations

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< size_t > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::pset_locations
protected

Accumulated number of vectors included in the support.

Definition at line 88 of file model-bones.hpp.

◆ pset_probs

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< double > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::pset_probs
protected

Probabilities of the support(s)

Definition at line 86 of file model-bones.hpp.

◆ pset_sizes

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< size_t > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::pset_sizes
protected

Number of vectors included in the support.

Definition at line 87 of file model-bones.hpp.

◆ pset_stats

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< double > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::pset_stats
protected

Statistics of the support(s)

Definition at line 85 of file model-bones.hpp.

◆ rengine

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::mt19937* Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::rengine = nullptr
protected

Definition at line 42 of file model-bones.hpp.

◆ rules

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
Rules<Array_Type,Data_Rule_Type>* Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::rules
protected

Definition at line 97 of file model-bones.hpp.

◆ rules_dyn

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
Rules<Array_Type,Data_Rule_Dyn_Type>* Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::rules_dyn
protected

Definition at line 98 of file model-bones.hpp.

◆ stats_likelihood

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< double > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::stats_likelihood
protected

Definition at line 67 of file model-bones.hpp.

◆ stats_support

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< double > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::stats_support
protected

Sufficient statistics of the model (support)

Definition at line 62 of file model-bones.hpp.

◆ stats_support_n_arrays

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< size_t > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::stats_support_n_arrays
protected

Number of arrays included per support.

Definition at line 65 of file model-bones.hpp.

◆ stats_support_sizes

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< size_t > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::stats_support_sizes
protected

Number of vectors included in the support.

Definition at line 63 of file model-bones.hpp.

◆ stats_support_sizes_acc

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< size_t > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::stats_support_sizes_acc
protected

Accumulated number of vectors included in the support.

Definition at line 64 of file model-bones.hpp.

◆ stats_target

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< std::vector< double > > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::stats_target
protected

Target statistics of the model.

Definition at line 66 of file model-bones.hpp.

◆ support_fun

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
Support<Array_Type,Data_Counter_Type,Data_Rule_Type,Data_Rule_Dyn_Type> Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::support_fun
protected

Definition at line 99 of file model-bones.hpp.

◆ transform_model_fun

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::function<std::vector<double>double *, size_t k)> Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::transform_model_fun = nullptr
protected

Transformation of the model.

When specified, this function will update the model by modifying the linear equation. For example, if the user wanted to add interaction terms, rescale, or apply other operations of the sorts, the user can do such through this function.

The function should return void and receive the following arguments:

  • data Pointer to the first element of the set of sufficient statistics
  • k size_t indicating the number of sufficient statistics
Returns
Nothing, but it will modify the model data.

Definition at line 128 of file model-bones.hpp.

◆ transform_model_term_names

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< std::string > Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::transform_model_term_names
protected

Definition at line 130 of file model-bones.hpp.

◆ with_pset

template<typename Array_Type = BArray<>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
bool Model< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::with_pset = false
protected

Definition at line 83 of file model-bones.hpp.


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