GOBNILP  f164d83
Data Structures | Macros | Typedefs | Functions
scoring.c File Reference

Generates local scores from discrete data using AD trees. More...

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#include "scoring.h"
#include "utils.h"
#include "versiongit.h"
Include dependency graph for scoring.c:

Data Structures

union  adcontab
 A contingency table. More...
 
struct  adtree
 represents data for a 'query', e.g. X1=1,X3=2 More...
 
struct  scored_parentset
 Parent set with its score Note that the child variable is not represented. More...
 
struct  subset_tree
 stores a set of downward closed subsets of the variables in a tree More...
 
struct  varynode
 for splitting data on values of a particular variable (variable not stored in varynode) More...
 

Macros

#define BLOCKSIZE   10000
 
#define MAXARITY   UCHAR_MAX
 
#define min(A, B)   ((A) < (B) ? (A) : (B))
 

Typedefs

typedef union adcontab ADCONTAB
 A contingency table.
 
typedef struct adtree ADTREE
 An AD tree.
 
typedef unsigned char ARITY
 Arity of a variable in the data.
 
typedef unsigned int COUNT
 Count, typically of datapoints.
 
typedef unsigned int ROW
 Index of a row (i.e. datapoint) in the data.
 
typedef double SCORE
 A local score. More...
 
typedef double SCOREARG
 An argument for a local score function. More...
 
typedef struct scored_parentset SCORED_PARENTSET
 parent set with its local score
 
typedef struct subset_tree SUBSET_TREE
 subset tree
 
typedef unsigned char VALUE
 Value of a variable in the data.
 
typedef unsigned int VARIABLE
 Variable in the data.
 
typedef struct varynode VARYNODE
 A varynode (in an AD tree)
 

Functions

static void add_subset (SUBSET_TREE *tree, SUBSET_TREE *bottom_ptr, VARIABLE *vars, int num_vars, VARIABLE offset, const VARIABLE nvars)
 Add a subset to the tree (if not already there ) More...
 
static SCIP_RETCODE addGeneralDAGConstraints (SCIP *scip, ParentSetData *psd, int **is_parent)
 Reads in structural constraints to restrict which parent sets are considered. More...
 
static SCIP_RETCODE addParentSets (SCIP *scip, VARIABLE child, SCORED_PARENTSET **parent_sets, int num_parent_sets, ParentSetData *psd, SCIP_Real ***scores)
 Record local scores for parent sets of a particular child. More...
 
static void build_adtree (ADTREE *adtree, const VARIABLE variable, ROW *theserows, COUNT count, const int rmin, const int depth, int *n_nodes, const int adtreedepthlim, const int adtreenodeslim, const VARIABLE nvars, VALUE **data, ARITY *arity)
 Build an AD tree from (a subset of) the data. More...
 
static void build_varynode (VARYNODE *varynode, VARIABLE variable, ROW *theserows, COUNT count, const int rmin, int depth, int *n_nodes, const int adtreedepthlim, const int adtreenodeslim, VARIABLE nvars, VALUE **data, ARITY *arity)
 Build an vary node from (a subset of) the data. More...
 
static SCIP_Bool check_subset (SUBSET_TREE *tree, SUBSET_TREE *bottom_ptr, VARIABLE *vars, int num_vars, VARIABLE offset)
 Check whether a particular subset of variables is stored in a tree of subsets. More...
 
static SCIP_RETCODE ci_constraint (SCIP *scip, ParentSetData *psd, const char *a_str, const char *b_str, const char *s_str, int **is_parent)
 Use a conditional independence (ci) constraint $ A \perp B | S $ to rule out parents. More...
 
static void delete_adtree (ADTREE *adtree, const VARIABLE variable, VARIABLE nvars, ARITY *arity)
 Delete an AD tree. More...
 
static void delete_contab (ADCONTAB adcontab, VARIABLE *variables, int nvariables, const ARITY *arity)
 Delete a contingency table. More...
 
static void delete_tree (SUBSET_TREE *tree, SUBSET_TREE *bottom_ptr, VARIABLE length)
 Delete a tree of subsets. More...
 
static SCORE log_likelihood (const ADCONTAB *adcontab, VARIABLE *variables, int nvariables, const SCOREARG aijk, const SCORE lgaijk, COUNT *npos_cells_ptr, const ARITY *arity, SCIP_Bool fast)
 Compute the (marginal) log-likelihood for a subset of the variables (modulo a constant) More...
 
static SCORE log_likelihood_cache (SCIP *scip, const ADTREE *adtree, VARIABLE *variables, int nvariables, COUNT *npos_cells_ptr, const int nvarscachelimit, const int cachesizelimit, const int cacheblocksize, int *cachesize_ptr, SCORE **llh_cache_ptr, COUNT **pos_cells_cache_ptr, const double alpha, const ARITY *arity, SCIP_Bool fast, VALUE **data, int *nsubsets)
 Compute the (marginal) log-likelihood for a subset of the variables and store in cache, or retrieve from cache if already computed. More...
 
static int lookup (char **names, ARITY length, ARITY *used, char *name)
 Find the integer encoding for (the string representation of) a value of a variable. More...
 
static void makecontab (const ADTREE *adtree, VARIABLE offset, VARIABLE *variables, int nvariables, ADCONTAB *adcontab, VALUE **data, const ARITY *arity)
 Construct a contingency table from an adtree. More...
 
static void makecontableaf (const ROW *leaflist, const COUNT count, VARIABLE *variables, int nvariables, ADCONTAB *adcontab, VALUE **data, const ARITY *arity)
 Construct a contingency table from a leaflist ( contingency table must be for at least one variable ) More...
 
static SCIP_RETCODE parseSet (SCIP *scip, ParentSetData *psd, const char *str, int *set, int *n_set, SCIP_Bool *success)
 Parses a string to extract a set from it. More...
 
static SCIP_RETCODE process_constraint (SCIP *scip, ParentSetData *psd, const char *line, int **is_parent)
 Processes a constraint on the DAG structure. More...
 
static int rank_subset (VARIABLE *variables, int nvariables, int *nsubsets)
 Map a subset of (BN) variables to a unique index. More...
 
static SCIP_RETCODE readProblemFromFile (SCIP *scip, const char *filename, int num_delims, char *delims, SCIP_Bool merge_delims, char ***nodeNames, ARITY **arities, VALUE ***items, int *num_vars, int *num_rows, char ****labels, int **num_observed)
 Read discrete data from a file. More...
 
SCIP_RETCODE SC_addScoringParameters (SCIP *scip)
 Add scoring parameters. More...
 
SCIP_RETCODE SC_readProblemInDataFormat (SCIP *scip, const char *filename, int num_delims, char *delims, SCIP_Bool merge_delims, ParentSetData *psd, SCIP_Real ***scores, PropertyData *prop)
 Read data in from a file, generate and store local scores. More...
 
static int sps_sort (const void *p1, const void *p2)
 Compare two scored parent sets according to score. More...
 
static void subtract_contab (ADCONTAB *adcontab1, const ADCONTAB *adcontab2, VARIABLE *variables, int nvariables, const ARITY *arity)
 Subtract one contingency table from another. More...
 

Detailed Description

Generates local scores from discrete data using AD trees.

Author
James Cussens
Mark Bartlett

Typedef Documentation

◆ SCORE

typedef double SCORE

A local score.

Currently only BDeu implemented

◆ SCOREARG

typedef double SCOREARG

An argument for a local score function.

Function Documentation

◆ add_subset()

static void add_subset ( SUBSET_TREE tree,
SUBSET_TREE bottom_ptr,
VARIABLE vars,
int  num_vars,
VARIABLE  offset,
const VARIABLE  nvars 
)
static

Add a subset to the tree (if not already there )

Parameters
treeSet of subsets of variables
bottom_ptrIndicates non-null leaf nodes
varsThe subset of variables to add
num_varsThe number of variables in the subset
offsetOffset for this node
nvarsNumber of variables in the data

References build_varynode(), adtree::count, and scored_parentset::nvars.

Here is the call graph for this function:

◆ addGeneralDAGConstraints()

static SCIP_RETCODE addGeneralDAGConstraints ( SCIP *  scip,
ParentSetData psd,
int **  is_parent 
)
static

Reads in structural constraints to restrict which parent sets are considered.

(Altered version of function of same name in probdata_bn.c)

Parameters
scipThe SCIP instance to add the constraint to.
psdThe parent set data relating to this problem, only nodeNames is set.
is_parentis_parent[i][j] = 1 (-1) if j must (not) be a parent of i
Returns
SCIP_OKAY if the constraints could be successfully added.

References process_constraint().

Here is the call graph for this function:

◆ addParentSets()

static SCIP_RETCODE addParentSets ( SCIP *  scip,
VARIABLE  child,
SCORED_PARENTSET **  parent_sets,
int  num_parent_sets,
ParentSetData psd,
SCIP_Real ***  scores 
)
static

Record local scores for parent sets of a particular child.

Parameters
scipSCIP data structure
childChild variable whose scored parent sets are being added
parent_setsScored parent sets for child
num_parent_setsThe number of scored parent sets for child
psdParent set data to populate
scores(*scores)[child][j] will be the score for the jth parent set of child

References ParentSetData::nParents, ParentSetData::nParentSets, scored_parentset::nvars, ParentSetData::ParentSets, scored_parentset::score, and scored_parentset::vars.

◆ build_adtree()

static void build_adtree ( ADTREE adtree,
const VARIABLE  variable,
ROW theserows,
COUNT  count,
const int  rmin,
const int  depth,
int *  n_nodes,
const int  adtreedepthlim,
const int  adtreenodeslim,
const VARIABLE  nvars,
VALUE **  data,
ARITY arity 
)
static

Build an AD tree from (a subset of) the data.

Parameters
adtreepointer to ADTREE being built
variablefirst variable to specialise further on, if variable=nvars then there is none
theserowsdatapoint indices for this tree
countnumber of datapoints for this tree
rminif count below this then create a leaflist
depththe depth of this node
n_nodes(pointer to) the number of nodes in the ADTREE
adtreedepthlimlimit on the depth of the ADTREE
adtreenodeslimlimit on the number of nodes in the ADTREE
nvarsNumber of variables in the data
datadata[i][j] is the value of variable i in row j
arityarity[i] is the arity of variable i,

References build_varynode(), adtree::children, adtree::count, adtree::leaflist, and scored_parentset::nvars.

Referenced by build_varynode().

Here is the call graph for this function:

◆ build_varynode()

static void build_varynode ( VARYNODE varynode,
VARIABLE  variable,
ROW theserows,
COUNT  count,
int  rmin,
const int  depth,
int *  n_nodes,
const int  adtreedepthlim,
const int  adtreenodeslim,
VARIABLE  nvars,
VALUE **  data,
ARITY arity 
)
static

Build an vary node from (a subset of) the data.

Parameters
varynodevarynode being built
variablewhich variable is being split
theserowsdatapoint indices to divide between values of variable
countnumber of datapoints for this tree
depththe depth of this node
n_nodes(pointer to) the number of nodes in the ADTREE
adtreedepthlimlimit on the depth of the ADTREE
adtreenodeslimlimit on the number of nodes in the ADTREE
nvarsNumber of variables in the data
datadata[i][j] is the value of variable i in row j
arityarity[i] is the arity of variable i,

References build_adtree(), varynode::children, adtree::count, and varynode::mcv.

Referenced by add_subset(), and build_adtree().

Here is the call graph for this function:

◆ check_subset()

static SCIP_Bool check_subset ( SUBSET_TREE tree,
SUBSET_TREE bottom_ptr,
VARIABLE vars,
int  num_vars,
VARIABLE  offset 
)
static

Check whether a particular subset of variables is stored in a tree of subsets.

Returns
True iff the subset is stored in the tree of subsets
Parameters
treeSet of subsets of variables
bottom_ptrIndicates non-null leaf nodes
varsThe subset of variables to look for
num_varsThe number of variables in the subset
offsetOffset for this node

◆ ci_constraint()

static SCIP_RETCODE ci_constraint ( SCIP *  scip,
ParentSetData psd,
const char *  a_str,
const char *  b_str,
const char *  s_str,
int **  is_parent 
)
static

Use a conditional independence (ci) constraint $ A \perp B | S $ to rule out parents.

$ A, B$ and $ S $ are given as comma separated variable names

Parameters
scipThe SCIP instance in which to add the constraint.
psdThe parent set data for the problem.
a_strA set
b_strB set
s_strS (separator) set. ( not used )
is_parentis_parent[i][j] is set to 1 (-1) if j can(not) be a parent of i
Returns
SCIP_OKAY if the constraint was added successfully or an error code otherwise.

References parseSet().

Referenced by process_constraint().

Here is the call graph for this function:

◆ delete_adtree()

static void delete_adtree ( ADTREE adtree,
const VARIABLE  variable,
VARIABLE  nvars,
ARITY arity 
)
static

Delete an AD tree.

Parameters
adtreepointer to ADTREE being deleted
variablefirst variable to specialise further on, if variable=nvars then there is none
nvarsNumber of variables in the data
arityarity[i] is the arity of variable i,

References adtree::children, varynode::children, adtree::leaflist, and scored_parentset::nvars.

◆ delete_contab()

static void delete_contab ( ADCONTAB  adcontab,
VARIABLE variables,
int  nvariables,
const ARITY arity 
)
static

Delete a contingency table.

The contingency table must have at least one variable (i.e. it cannot be a count), but this only checked for in DEBUG mode.

Parameters
adcontabContingency table to delete
variablesVariables in the contingency table
nvariablesNumber of variables in the contingency table (must be positive)
arityarity[i] is the arity of variable i,

References adcontab::children.

Referenced by log_likelihood_cache().

◆ delete_tree()

static void delete_tree ( SUBSET_TREE tree,
SUBSET_TREE bottom_ptr,
VARIABLE  length 
)
static

Delete a tree of subsets.

Parameters
treeTree of subsets to delete
bottom_ptrIndicates non-null leaf nodes
lengthNumber of children of this node

◆ log_likelihood()

static SCORE log_likelihood ( const ADCONTAB adcontab,
VARIABLE variables,
int  nvariables,
const SCOREARG  aijk,
const SCORE  lgaijk,
COUNT npos_cells_ptr,
const ARITY arity,
SCIP_Bool  fast 
)
static

Compute the (marginal) log-likelihood for a subset of the variables (modulo a constant)

To get the true log-likelihood one would need to add lgamma(alpha) - log(alpha+N) to the result of this function, where N is the number of samples. Since local scores are always computed as this_function(family)-this_function(parents), there is no need to compute the constant term

Parameters
adcontabcontingency table for variables
variablesthe subset of the variables
nvariablesthe size of the subset of the variables
aijkeffective samples size (ESS) divided by the number of joint instantiations of the subset of variables
lgaijklog(Gamma(aijk))
npos_cells_ptrpointer to number of cells in adcontab with a positive count
arityarity[i] is the arity of variable i,
fastIf true then C's lgamma function is used for computing scores, otherwise a slower, more accurate sum of logs

References adcontab::children, and adcontab::count.

Referenced by log_likelihood_cache().

◆ log_likelihood_cache()

static SCORE log_likelihood_cache ( SCIP *  scip,
const ADTREE adtree,
VARIABLE variables,
int  nvariables,
COUNT npos_cells_ptr,
const int  nvarscachelimit,
const int  cachesizelimit,
const int  cacheblocksize,
int *  cachesize_ptr,
SCORE **  llh_cache_ptr,
COUNT **  pos_cells_cache_ptr,
const double  alpha,
const ARITY arity,
SCIP_Bool  fast,
VALUE **  data,
int *  nsubsets 
)
static

Compute the (marginal) log-likelihood for a subset of the variables and store in cache, or retrieve from cache if already computed.

Parameters
scipSCIP instance
adtreethe data
variablesthe subset of the variables
nvariablesthe size of the subset of the variables
npos_cells_ptrpointer to number of cells in adcontab with a positive count
nvarscachelimitsubsets must have size below this to be cached.
cachesizelimitthe maximum number of log-likelihoods and pos_cell_cache values to cache (limit is common to both).
cacheblocksizehow much to increase the size of the cache for log-likelihoods and pos_cell_cache values when it is too small (common to both).
cachesize_ptr(pointer to) the current size of the cache for log-likelihoods and pos_cell_cache values (common to both)
llh_cache_ptr(pointer to) llh_cache[r] is the log-likelihood for (the data projected onto ) the unique subset of variables with rank r
pos_cells_cache_ptr(pointer to) pos_cell_cache[r] is the number of non-zero counts in the contingency table for the unique subset of variables with rank r. A value of zero indicates that neither the correct count nor the the associated llh_cache[r] value has yet been computed
alphaThe 'effective sample size' governing the BDeu score
arityarity[i] is the arity of variable i,
fastIf true then C's lgamma function is used for computing scores, otherwise a slower, more accurate sum of logs
datadata[i][j] is the value of variable i in row j
nsubsetsnsubsets[nvariables] is how many susbsets have size strictly less than nvariables

References delete_contab(), log_likelihood(), makecontab(), and rank_subset().

Here is the call graph for this function:

◆ lookup()

static int lookup ( char **  names,
ARITY  length,
ARITY used,
char *  name 
)
static

Find the integer encoding for (the string representation of) a value of a variable.

If the input string name does not occurs in names, then it will be added to it (as long as doing so would not exceed the arity), and (*used) will be incremented.

Returns
the integer encoding the value, or -1 not possible due to exceeding the given variable arity length.
Parameters
namesnames[r] is (the string representation of) the rth value of the variable
lengtharity of the variable (number of values the variable has)
usedthe number of strings stored in names
name(string representation of) a value of a variable

References BgeMatrixCreate(), and UT_readFileAndSplit().

Here is the call graph for this function:

◆ makecontab()

static void makecontab ( const ADTREE adtree,
VARIABLE  offset,
VARIABLE variables,
int  nvariables,
ADCONTAB adcontab,
VALUE **  data,
const ARITY arity 
)
static

Construct a contingency table from an adtree.

Parameters
adtree(Pointer to) the ADTREE or NULL
offsetOffset for first variable (to identify correct vary nodes)
variablesVariables in the sought contingency table (sorted)
nvariablesNumber of variables in the contingency table
adcontabReturned contingency table
datadata[i][j] is the value of variable i in row j
arityarity[i] is the arity of variable i,

References adtree::children, varynode::children, adcontab::children, adtree::count, adcontab::count, adtree::leaflist, makecontableaf(), varynode::mcv, and subtract_contab().

Referenced by log_likelihood_cache().

Here is the call graph for this function:

◆ makecontableaf()

static void makecontableaf ( const ROW leaflist,
const COUNT  count,
VARIABLE variables,
int  nvariables,
ADCONTAB adcontab,
VALUE **  data,
const ARITY arity 
)
static

Construct a contingency table from a leaflist ( contingency table must be for at least one variable )

Parameters
leaflistdatapoints for this query
countnumber of datapoints (in leaflist)
variablesvariables in the contingency table (sorted)
nvariablesnumber of variables in the contigency table
adcontab(pointer to ) returned contingency table
datadata[i][j] is the value of variable i in row j
arityarity[i] is the arity of variable i,

References adtree::children, adcontab::children, adtree::count, and adcontab::count.

Referenced by makecontab().

◆ parseSet()

static SCIP_RETCODE parseSet ( SCIP *  scip,
ParentSetData psd,
const char *  str,
int *  set,
int *  n_set,
SCIP_Bool *  success 
)
static

Parses a string to extract a set from it.

Copied from probdata_bn

Parameters
scipThe SCIP instance that this belongs to.
psdThe data set that the set refers to.
strstring to parse
setresult set
n_setlength of set
successsuccess flag

References get_index().

Referenced by ci_constraint().

Here is the call graph for this function:

◆ process_constraint()

static SCIP_RETCODE process_constraint ( SCIP *  scip,
ParentSetData psd,
const char *  line,
int **  is_parent 
)
static

Processes a constraint on the DAG structure.

Parameters
scipThe SCIP instance in which to add the constraint.
psdThe parent set data relating to this problem, only nodeNames is set.
lineThe description of the constraint to add.
is_parentis_parent[i][j] is set to 1 (-1) if j can(not) be a parent of i
Returns
SCIP_OKAY if the constraint was added or an error otherwise.

References ci_constraint(), get_index(), and ParentSetData::n.

Referenced by addGeneralDAGConstraints().

Here is the call graph for this function:

◆ rank_subset()

static int rank_subset ( VARIABLE variables,
int  nvariables,
int *  nsubsets 
)
static

Map a subset of (BN) variables to a unique index.

If A is a subset of B then rank(A) < rank(B)

Returns
The rank of the subset
Parameters
variablesthe subset of the variables
nvariablesthe size of the subset of the variables
nsubsetsnsubsets[nvariables] is how many susbsets have size strictly less than nvariables

Referenced by log_likelihood_cache().

◆ readProblemFromFile()

static SCIP_RETCODE readProblemFromFile ( SCIP *  scip,
const char *  filename,
int  num_delims,
char *  delims,
SCIP_Bool  merge_delims,
char ***  nodeNames,
ARITY **  arities,
VALUE ***  items,
int *  num_vars,
int *  num_rows,
char ****  labels,
int **  num_observed 
)
static

Read discrete data from a file.

The last 7 arguments are outputs for which we use pointers. This function allocates space for these outputs.

Parameters
scipSCIP data structure
filenameFile containing the data
num_delimsThe number of field delimiters to use
delimsThe field delimiters to use
merge_delimsWhether multiple field delimiters should be merged in to one
nodeNames(Pointer to) node (i.e. variable) names
arities(Pointer to) node variable arities
items(Pointer to) the data. &c (*items)[i][j] is the integer-encoded value of the ith variable in the jth datapoint
num_vars(Pointer to) the number of variables
num_rows(Pointer to) the number of rows (i.e. datapoints) in the data
labels(Pointer to) a mapping from the integer encoding of a value to the corresponding string (*labels)[i][r] is the string corresponding to the rth value of the ith variable
num_observed(Pointer to) the number of distinct values observed in the data for each variable

References UT_readFileAndSplit().

Here is the call graph for this function:

◆ SC_addScoringParameters()

SCIP_RETCODE SC_addScoringParameters ( SCIP *  scip)

Add scoring parameters.

Parameters
scipSCIP data structure

References UT_addBoolParam(), UT_addIntParam(), and UT_addRealParam().

Referenced by BN_addParameters().

Here is the call graph for this function:

◆ SC_readProblemInDataFormat()

SCIP_RETCODE SC_readProblemInDataFormat ( SCIP *  scip,
const char *  filename,
int  num_delims,
char *  delims,
SCIP_Bool  merge_delims,
ParentSetData psd,
SCIP_Real ***  scores,
PropertyData prop 
)

Read data in from a file, generate and store local scores.

This function sets the global variables alpha, palim, fast, cachesizelimit, cacheblocksize, nvarscachelimit, nvars, arity, nrows and data.

See also
alpha, palim, fast, cachesizelimit, cacheblocksize, nvarscachelimit, nvars, arity, nrows and data Detailed information about e.g. scoring parameters as well as about the data is stored in a PropertyData data structure

< The 'effective sample size' governing the BDeu score

< Maximum allowed size for a parent set

< If true then C's lgamma function is used for computing scores, otherwise a slower, more accurate sum of logs

< the maximum number of log-likelihoods and pos_cell_cache values to cache (limit is common to both).

< how much to increase the size of the cache for log-likelihoods and pos_cell_cache values when it is too small (common to both).

< subsets must have size below this to be cached.

< arity[i] is the arity of variable i, (discrete)

< data[i][j] is the value of variable i in row j (discrete)

< Number of variables in the data

< Number of rows (i.e. datapoints) in the data

< the current size of the cache for log-likelihoods and pos_cell_cache values (common to both)

< llh_cache[r] is the log-likelihood for (the data projected onto ) the unique subset of variables with rank r

< pos_cell_cache[r] is the number of non-zero counts in the contingency table for the unique subset of variables with rank r.

< nsubsets[nvariables] is how many susbsets have size strictly less than nvariables

< Subset tree used to indicate leaf nodes. Its value is never set or used; it only exists for bottom_ptr to have something to point to.

See also
bottom_ptr

< Pointer to bottom.

See also
bottom
Parameters
scipSCIP data structure
filenameFile containing the data
num_delimsThe number of field delimiters to use
delimsThe field delimiters to use
merge_delimsWhether multiple field delimiters should be merged in to one
psdParent set data to populate
scores(*scores)[child][j] will be the score for the jth parent set of child
propProperty data structure

References scored_parentset::nvars.

Referenced by readProblemInNonCIPFormat().

◆ sps_sort()

static int sps_sort ( const void *  p1,
const void *  p2 
)
static

Compare two scored parent sets according to score.

For use with qsort, so arguments have type void*

Returns
-1 if first has higher score, else 1
Parameters
p1First scored parent set
p2Second scored parent set

◆ subtract_contab()

static void subtract_contab ( ADCONTAB adcontab1,
const ADCONTAB adcontab2,
VARIABLE variables,
int  nvariables,
const ARITY arity 
)
static

Subtract one contingency table from another.

The two contingency tables must be over the same variables

Parameters
adcontab1Contingency table from which adcontab2 will be subtracted
adcontab2Contingency table which will be subtracted from adcontab1
variablesVariables common to both adcontab1 and adcontab2
nvariablesNumber of variables
arityarity[i] is the arity of variable i,

References adcontab::children, adtree::count, and adcontab::count.

Referenced by makecontab().