Doxygen
1.9.1
|
Contains the current state and the history of the DREAM chains. More...
#include <tsgDreamState.hpp>
Public Member Functions | |
TasmanianDREAM () | |
Constructor for a null DREAM state, no chains and no dimensions (used for MPI purposes). | |
TasmanianDREAM (int cnum_chains, int cnum_dimensions) | |
Constructor for a DREAM state with the number of chains and dimensions. | |
TasmanianDREAM (int cnum_chains, const TasGrid::TasmanianSparseGrid &grid) | |
Constructor for a DREAM state with the number of chains and the dimension of the sparse grid. | |
~TasmanianDREAM () | |
Default destructor, release all used memory. | |
int | getNumDimensions () const |
Return the number of dimensions. | |
int | getNumChains () const |
Return the number of chains. | |
size_t | getNumHistory () const |
Return the number of saved vectors in the history. | |
bool | isStateReady () const |
Return true if the state has already been initialized with setState(). | |
bool | isPDFReady () const |
Return true if the pdf values have already been initialized with setPDF(). | |
void | setState (const std::vector< double > &new_state) |
Set the current DREAM state to the new_state. More... | |
void | setState (std::function< void(double *)> update_state) |
Set the current DREAM state by calling update_state on each vector. More... | |
void | setPDFvalues (const std::vector< double > &new_values) |
Set the current set of pdf values to the new_values. More... | |
void | setPDFvalues (std::function< void(const std::vector< double > &state, std::vector< double > &values)> probability_distribution) |
Set the current set of pdf values using the given probability_distribution. More... | |
void | clearPDFvalues () |
Erase the currently stored pdf values, useful when switching between log and non-log form sampling. | |
void | getIJKdelta (size_t i, size_t j, size_t k, double w, std::vector< double > &x) const |
Used by the DREAM sampler, ![]() | |
void | getChainState (size_t i, double *x) const |
Return the state of the i-th chain, store an array x of size at least num_dimensions. More... | |
const std::vector< double > & | getChainState () const |
Return a const reference to the internal state vector. | |
double | getPDFvalue (size_t i) const |
Return the value of the probability_distribution of the i-th chain. More... | |
void | expandHistory (int num_snapshots) |
Allocate (expand) internal storage for the history snapshots, avoids reallocating data when saving a snapshot. More... | |
void | saveStateHistory (size_t num_accepted) |
Appends the current state to the history. More... | |
const std::vector< double > & | getHistory () const |
Return a const reference to the internal state vector. | |
const std::vector< double > & | getHistoryPDF () const |
Return a const reference to the internal state vector. | |
void | getHistoryMeanVariance (std::vector< double > &mean, std::vector< double > &var) const |
Compute the means and variance of the saved history. | |
void | getApproximateMode (std::vector< double > &mode) const |
Return the sample with highest probability, searchers within the history. | |
std::vector< double > | getApproximateMode () const |
Overload that returns the vector. | |
void | clearHistory () |
Clear the stored history (does not touch the state). | |
double | getAcceptanceRate () const |
Returns the acceptance rate of the current history. | |
Static Public Member Functions | |
static const char * | getVersion () |
Return human readable string with the version. | |
static const char * | getLicense () |
Return human readable sting with the license, refer to the LICENSE file for details. | |
static int | getVersionMajor () |
Return the major version of the library. | |
static int | getVersionMinor () |
Return the minor version of the library. | |
Contains the current state and the history of the DREAM chains.
void TasDREAM::TasmanianDREAM::setState | ( | const std::vector< double > & | new_state | ) |
Set the current DREAM state to the new_state.
The new_state must have size equal to num_chains times num_dimensions, the first chain should be stored in the first num_dimensions entries, the second chain in the second batch of num_dimensions entries, and so on.
void TasDREAM::TasmanianDREAM::setState | ( | std::function< void(double *)> | update_state | ) |
Set the current DREAM state by calling update_state on each vector.
The update_state function will be given each state vector as an array and the function should overwrite the entries with the desired current state. For example, update_state can overwrite the array with random numbers sampled according to a desired probability distribution.
void TasDREAM::TasmanianDREAM::setPDFvalues | ( | const std::vector< double > & | new_values | ) |
Set the current set of pdf values to the new_values.
The new_values must have size equal to the number of chains, the current set of pdf values are overwritten with the new ones. Note: that there is no restriction on the sign of the values, since log-form sampling can result in negative values.
void TasDREAM::TasmanianDREAM::setPDFvalues | ( | std::function< void(const std::vector< double > &state, std::vector< double > &values)> | probability_distribution | ) |
Set the current set of pdf values using the given probability_distribution.
Calls the probability_distribution function wit the current state (the state must be already initialized). The probability_distribution is the same function as in the DREAM sampling call, in order to avoid discrepancy, it may be best to leave the PDF values uninitialized and let the DREAM sampler to call setPDFvalues() automatically.
void TasDREAM::TasmanianDREAM::getIJKdelta | ( | size_t | i, |
size_t | j, | ||
size_t | k, | ||
double | w, | ||
std::vector< double > & | x | ||
) | const |
Used by the DREAM sampler, , where s indicates the current i, j, and k-th state vectors.
Used by the DREAM sampler and probably should not be called by the user. This returns the vector of the i-th chain corrected by the difference between the k-th and j-th chain and weighted by w. The result is written to the array x, which must have size at least num_dimensions.
|
inline |
Return the state of the i-th chain, store an array x of size at least num_dimensions.
Used by the DREAM sampler and probably should not be called by the user.
|
inline |
Return the value of the probability_distribution of the i-th chain.
Used by the DREAM sampler and probably should not be called by the user.
void TasDREAM::TasmanianDREAM::expandHistory | ( | int | num_snapshots | ) |
Allocate (expand) internal storage for the history snapshots, avoids reallocating data when saving a snapshot.
Used by the DREAM sampler and probably should not be called by the user.
void TasDREAM::TasmanianDREAM::saveStateHistory | ( | size_t | num_accepted | ) |
Appends the current state to the history.
Used by the DREAM sampler and probably should not be called by the user; num_accepted is the number of new chains in the state.