42 #include "../VectorTools.h" 52 const std::vector<size_t>& nrowt,
53 const std::vector<size_t>& ncolt):
65 throw Exception(
"ContingencyTableGenerator. Input marginals must have size greater than 1.");
68 throw Exception(
"ContingencyTableGenerator. Marginal do not sum to the same value.");
74 for (
unsigned int i = 1; i <=
ntot_; i++) {
75 x = x + log(static_cast<double>(i));
94 size_t j, l, m, ia, ib, ic, jc, id, ie, ii, nll, nlm, nr_1, nc_1;
95 long double x, y, dummy, sumprb;
104 for (j = 0; j < nc_1; ++j)
109 for (l = 0; l < nr_1; ++l) {
114 for (m = 0; m < nc_1; ++m) {
122 for (j = m; j < nc_1; ++j)
135 nlm =
static_cast<size_t>(ia * (
static_cast<long double>(id) / static_cast<long double>(ie)) + 0.5);
148 j =
static_cast<size_t>((
id - nlm) * static_cast<long double>(ia - nlm));
152 x = x * j / (
static_cast<long double>(nlm) * (ii + nlm));
160 j = nll * (ii + nll);
164 y = y * j / (
static_cast<long double>(
id - nll) * (ia - nll));
166 if (sumprb >= dummy) {
190 for (m = 0; m < nc_1; ++m)
191 table(nr_1, m) =
jwork_[m];
193 table(nr_1, nc_1) = ib - table(nr_1, nc_1 - 1);
This class allows to perform a correspondence analysis.
This is the interface for the Random Number Generators.
virtual double drawNumber() const =0
Return a random number.
std::vector< size_t > ncolt_
RowMatrix< size_t > rcont2(const RandomFactory &generator= *RandomTools::DEFAULT_GENERATOR)
std::vector< size_t > nrowt_
std::vector< size_t > jwork_
std::vector< double > fact_
ContingencyTableGenerator(const std::vector< size_t > &nrowt, const std::vector< size_t > &ncolt)