43 #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++)
76 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)
111 for (l = 0; l < nr_1; ++l)
117 for (m = 0; m < nc_1; ++m)
127 for (j = m; j < nc_1; ++j)
143 nlm =
static_cast<size_t>(ia * (
static_cast<long double>(id) /
static_cast<long double>(ie)) + 0.5);
157 j =
static_cast<size_t>((
id - nlm) *
static_cast<long double>(ia - nlm));
162 x = x * j / (
static_cast<long double>(nlm) * (ii + nlm));
171 j = nll * (ii + nll);
176 y = y * j / (
static_cast<long double>(
id - nll) * (ia - nll));
205 for (m = 0; m < nc_1; ++m)
207 table(nr_1, m) =
jwork_[m];
210 table(nr_1, nc_1) = ib - table(nr_1, nc_1 - 1);
std::vector< size_t > nrowt_
std::vector< size_t > ncolt_
RowMatrix< size_t > rcont2(const RandomFactory &generator= *RandomTools::DEFAULT_GENERATOR)
std::vector< size_t > jwork_
std::vector< double > fact_
ContingencyTableGenerator(const std::vector< size_t > &nrowt, const std::vector< size_t > &ncolt)
Exception base class. Overload exception constructor (to control the exceptions mechanism)....
This is the interface for the Random Number Generators.
virtual double drawNumber() const =0
Return a random number.