| Signature | Description | Parameters |
|---|---|---|
template<typename T> std::vector<T> MC_station_dist(std::vector<const char *> &&trans_col_name, size_type max_iter = 1000, T epsilon = T(1e-8)) const; |
Markov Chains Stationary Distributions A stationary distribution in the context of Markov Chains refers to a probability distribution that remains unchanged over time, meaning if a Markov chain starts in this distribution, it will always stay in that same distribution regardless of how many steps are taken; essentially, it represents a stable state of the chain where the probabilities of being in each state do not fluctuate further. In probability theory and statistics, a Markov chain or Markov process is a stochastic process describing a sequence of possible events in which the probability of each event depends only on the state attained in the previous event. Informally, this may be thought of as; What happens next depends only on the state of affairs now. NOTE: This method solves the problem iteratively. If the returned vector is empty, it means the algorithm did not converge. |
T: Type of the named columns trans_col_names: Transition column names specifying the transition matrix max_iter: Maximum number of iterations epsilon: Threshold for convergence |
static void test_MC_station_dist() { std::cout << "\nTesting MC_station_dist( ) ..." << std::endl; const std::size_t item_cnt = 20; MyDataFrame df; df.load_index(MyDataFrame::gen_sequence_index(0, item_cnt, 1)); RandGenParams<double> p; std::vector<const char *> col_names (item_cnt, nullptr); p.seed = 0; df.load_column("0_col_name", gen_normal_dist<double, 256>(item_cnt, p)); for (std::size_t i = 1; i < item_cnt; ++i) { p.seed = i; df.load_column((std::to_string(i) + "_col_name").c_str(), gen_normal_dist<double, 256>(item_cnt, p)); } for (std::size_t i = 0; i < item_cnt; ++i) col_names[i] = df.col_idx_to_name(i); const auto result = df.MC_station_dist<double>(std::forward<std::vector<const char *>>(col_names)); assert(result.size() == 20); assert(std::fabs(result[0] - -0.705967) < 0.000001); assert(std::fabs(result[5] - 0.121566) < 0.000001); assert(std::fabs(result[15] - -0.639604) < 0.000001); assert(std::fabs(result[19] - -0.692765) < 0.000001); }