bpp-core3  3.0.0
bpp::ContingencyTableGenerator Class Reference

Generate a random contingency matrix with given marginal counts. More...

#include <Bpp/Numeric/Random/ContingencyTableGenerator.h>

+ Collaboration diagram for bpp::ContingencyTableGenerator:

Public Member Functions

 ContingencyTableGenerator (const std::vector< size_t > &nrowt, const std::vector< size_t > &ncolt)
 
RowMatrix< size_t > rcont2 (const RandomFactory &generator= *RandomTools::DEFAULT_GENERATOR)
 

Private Attributes

std::vector< size_t > nrowt_
 
std::vector< size_t > ncolt_
 
size_t nrow_
 
size_t ncol_
 
size_t nrowm_
 
size_t ncolm_
 
std::vector< size_t > jwork_
 
size_t ntot_
 
std::vector< double > fact_
 

Detailed Description

Generate a random contingency matrix with given marginal counts.

This procedure was adapted from the original fortran code described in: Patefield, W. M. (1981) Algorithm AS159. An efficient method of generating r x c tables with given row and column totals. Applied Statistics 30, 91-97. This algorithm is the one also used in R function chisq.test for instance.

The code was adpated from file rcont.c, edited by Martin Maechler, Dec 2003, available in the R software source distribution.

Parameters
nrowtMarginal counts.
ncoltMarginal counts.
Returns
A random matrix of counts with the same marginals as specified.

Definition at line 71 of file ContingencyTableGenerator.h.

Constructor & Destructor Documentation

◆ ContingencyTableGenerator()

ContingencyTableGenerator::ContingencyTableGenerator ( const std::vector< size_t > &  nrowt,
const std::vector< size_t > &  ncolt 
)

Member Function Documentation

◆ rcont2()

RowMatrix< size_t > ContingencyTableGenerator::rcont2 ( const RandomFactory generator = RandomTools::DEFAULT_GENERATOR)

Member Data Documentation

◆ fact_

std::vector<double> bpp::ContingencyTableGenerator::fact_
private

Definition at line 82 of file ContingencyTableGenerator.h.

Referenced by ContingencyTableGenerator(), and rcont2().

◆ jwork_

std::vector<size_t> bpp::ContingencyTableGenerator::jwork_
private

Definition at line 80 of file ContingencyTableGenerator.h.

Referenced by rcont2().

◆ ncol_

size_t bpp::ContingencyTableGenerator::ncol_
private

Definition at line 77 of file ContingencyTableGenerator.h.

Referenced by ContingencyTableGenerator(), and rcont2().

◆ ncolm_

size_t bpp::ContingencyTableGenerator::ncolm_
private

Definition at line 79 of file ContingencyTableGenerator.h.

Referenced by ContingencyTableGenerator().

◆ ncolt_

std::vector<size_t> bpp::ContingencyTableGenerator::ncolt_
private

Definition at line 75 of file ContingencyTableGenerator.h.

Referenced by ContingencyTableGenerator(), and rcont2().

◆ nrow_

size_t bpp::ContingencyTableGenerator::nrow_
private

Definition at line 76 of file ContingencyTableGenerator.h.

Referenced by ContingencyTableGenerator(), and rcont2().

◆ nrowm_

size_t bpp::ContingencyTableGenerator::nrowm_
private

Definition at line 78 of file ContingencyTableGenerator.h.

Referenced by ContingencyTableGenerator().

◆ nrowt_

std::vector<size_t> bpp::ContingencyTableGenerator::nrowt_
private

Definition at line 74 of file ContingencyTableGenerator.h.

Referenced by ContingencyTableGenerator(), and rcont2().

◆ ntot_

size_t bpp::ContingencyTableGenerator::ntot_
private

Definition at line 81 of file ContingencyTableGenerator.h.

Referenced by ContingencyTableGenerator(), and rcont2().


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