KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
semantics::Marginal_cell< T, N > Class Template Reference

concrete class for contingency table cell More...

#include <Cell_traits.h>

Inheritance diagram for semantics::Marginal_cell< T, N >:
semantics::Marginal_cell_base semantics::Cell

Public Types

typedef Marginal_cell< T, N > Self
 
typedef boost::shared_ptr< SelfSelf_ptr
 
typedef Cell_traits< T, N > Traits
 
typedef
Marginal_cell_base::Self_ptr 
Base_ptr
 
typedef Context_cell_base::Self_ptr Context_base_ptr
 
typedef Categorical_event< N > Key_type
 
typedef boost::unordered_map
< Key_type, Self_ptr
Map
 
typedef Context_cell< T, N > Context_type
 
typedef boost::shared_ptr
< Context_type
Context_ptr
 
typedef Traits::Margin_type Margin_type
 
typedef boost::shared_ptr
< Margin_type
Margin_ptr
 
- Public Types inherited from semantics::Marginal_cell_base
typedef boost::shared_ptr
< Marginal_cell_base
Self_ptr
 
typedef boost::shared_ptr
< Context_cell_base
Context_ptr
 
typedef std::map< size_t, size_t > Table_count_map
 
- Public Types inherited from semantics::Cell
typedef boost::shared_ptr< CellSelf_ptr
 
typedef std::vector< size_t > Step_sizes
 

Public Member Functions

 Marginal_cell (const Key_type &key)
 ctor to create a new cell out of a key More...
 
 Marginal_cell (const Marginal_cell &other)
 copy ctor More...
 
virtual ~Marginal_cell ()
 destructor More...
 
const Key_typekey () const
 return data More...
 
Base_ptr margin () const
 get smoothed cell More...
 
Context_base_ptr context () const
 get conditioning context More...
 
void increment (const size_t &table_code)
 increment this cell and its relevant margins and contexts More...
 
void decrement (const size_t &table_code)
 decrement this cell and its relevant margins and contexts More...
 
void increment_table_count ()
 increment the number of distinct tables with this value More...
 
void decrement_table_count ()
 decrement the number of distinct tables with this value More...
 
size_t sample_table_assignment ()
 stochastically return a new table assignment for an observation More...
 
double backoff_probability () const
 prob of this outcome conditioned on starting a new table More...
 
double predictive_probability () const
 predictive probability of this outcome in this context More...
 
double smoothed_probability ()
 predictive probability under original Collins algorithm More...
 
- Public Member Functions inherited from semantics::Cell
const size_t & count () const
 get current count in this cell More...
 
const size_t & table_count () const
 get number of "tables" in this cell More...
 
virtual void increment ()
 increment count More...
 
virtual void decrement ()
 decrement count More...
 

Static Public Member Functions

static Self_ptr add_event (const Key_type &key, Cell::Step_sizes::const_reverse_iterator first, const size_t &size, const size_t &out_size)
 creates a new instance and sets its margin and context More...
 
static Context_ptr add_context_event (const typename Context_type::Key_type &key)
 creates a new context cell and returns a pointer to it More...
 

Static Public Attributes

static Map map
 
static bool & VERBOSE = Cell::VERBOSE
 
- Static Public Attributes inherited from semantics::Cell
static bool VERBOSE = false
 

Friends

std::ostream & operator (std::ostream &os, const Map &map)
 output a contingency table in human readable form to an ostream More...
 

Additional Inherited Members

- Protected Member Functions inherited from semantics::Marginal_cell_base
 Marginal_cell_base ()
 constructor More...
 
- Protected Member Functions inherited from semantics::Cell
 Cell ()
 default ctor More...
 
virtual ~Cell ()
 virtual destructor More...
 
- Protected Attributes inherited from semantics::Marginal_cell_base
Table_count_map per_table_counts_
 
- Protected Attributes inherited from semantics::Cell
size_t count_
 
size_t table_count_
 

Detailed Description

template<class T, size_t N>
class semantics::Marginal_cell< T, N >

concrete class for contingency table cell

Member Typedef Documentation

template<class T, size_t N>
typedef Marginal_cell_base::Self_ptr semantics::Marginal_cell< T, N >::Base_ptr
template<class T, size_t N>
typedef Context_cell_base::Self_ptr semantics::Marginal_cell< T, N >::Context_base_ptr
template<class T, size_t N>
typedef boost::shared_ptr<Context_type> semantics::Marginal_cell< T, N >::Context_ptr
template<class T, size_t N>
typedef Context_cell<T,N> semantics::Marginal_cell< T, N >::Context_type
template<class T, size_t N>
typedef Categorical_event<N> semantics::Marginal_cell< T, N >::Key_type
template<class T, size_t N>
typedef boost::unordered_map<Key_type, Self_ptr> semantics::Marginal_cell< T, N >::Map
template<class T, size_t N>
typedef boost::shared_ptr<Margin_type> semantics::Marginal_cell< T, N >::Margin_ptr
template<class T, size_t N>
typedef Traits::Margin_type semantics::Marginal_cell< T, N >::Margin_type
template<class T, size_t N>
typedef Marginal_cell<T,N> semantics::Marginal_cell< T, N >::Self
template<class T, size_t N>
typedef boost::shared_ptr<Self> semantics::Marginal_cell< T, N >::Self_ptr
template<class T, size_t N>
typedef Cell_traits<T,N> semantics::Marginal_cell< T, N >::Traits

Constructor & Destructor Documentation

template<class T , size_t N>
semantics::Marginal_cell< T, N >::Marginal_cell ( const Key_type key)

ctor to create a new cell out of a key

Parameters
keycontainer holding values of each categorical variable
template<class T , size_t N>
semantics::Marginal_cell< T, N >::Marginal_cell ( const Marginal_cell< T, N > &  other)

copy ctor

template<class T , size_t N>
semantics::Marginal_cell< T, N >::~Marginal_cell ( )
virtual

destructor

Member Function Documentation

template<typename T , size_t N>
Marginal_cell< T, N >::Context_ptr semantics::Marginal_cell< T, N >::add_context_event ( const typename Context_type::Key_type key)
static

creates a new context cell and returns a pointer to it

template<typename T , size_t N>
Marginal_cell< T, N >::Self_ptr semantics::Marginal_cell< T, N >::add_event ( const Key_type key,
Cell::Step_sizes::const_reverse_iterator  first,
const size_t &  size,
const size_t &  out_size 
)
static

creates a new instance and sets its margin and context

template<class T, size_t N>
double semantics::Marginal_cell< T, N >::backoff_probability ( ) const
inlinevirtual

prob of this outcome conditioned on starting a new table

corresponds to q(x,H) in the writeup

Implements semantics::Marginal_cell_base.

template<class T, size_t N>
Context_base_ptr semantics::Marginal_cell< T, N >::context ( ) const
inlinevirtual

get conditioning context

Implements semantics::Marginal_cell_base.

template<class T , size_t N>
void semantics::Marginal_cell< T, N >::decrement ( const size_t &  table_code)
virtual

decrement this cell and its relevant margins and contexts

Implements semantics::Marginal_cell_base.

template<class T , size_t N>
void semantics::Marginal_cell< T, N >::decrement_table_count ( )
virtual

decrement the number of distinct tables with this value

Reimplemented from semantics::Cell.

template<class T , size_t N>
void semantics::Marginal_cell< T, N >::increment ( const size_t &  table_code)
virtual

increment this cell and its relevant margins and contexts

Implements semantics::Marginal_cell_base.

template<class T , size_t N>
void semantics::Marginal_cell< T, N >::increment_table_count ( )
virtual

increment the number of distinct tables with this value

Reimplemented from semantics::Cell.

template<class T, size_t N>
const Key_type& semantics::Marginal_cell< T, N >::key ( ) const
inlinevirtual

return data

Implements semantics::Cell.

template<class T, size_t N>
Base_ptr semantics::Marginal_cell< T, N >::margin ( ) const
inlinevirtual

get smoothed cell

Implements semantics::Marginal_cell_base.

template<class T, size_t N>
double semantics::Marginal_cell< T, N >::predictive_probability ( ) const
inlinevirtual

predictive probability of this outcome in this context

corresponds to p(x|beta(H)) in the writeup, but is not normalized. normalization must occur later when comparing

Implements semantics::Marginal_cell_base.

template<class T, size_t N>
size_t semantics::Marginal_cell< T, N >::sample_table_assignment ( )
inlinevirtual

stochastically return a new table assignment for an observation

Returns
a new local index value

Uses the Hierarchical CRP mechanism to sample a new table assignment. Includes bookkeeping to recycle table indices

Implements semantics::Marginal_cell_base.

template<class T, size_t N>
double semantics::Marginal_cell< T, N >::smoothed_probability ( )
inlinevirtual

predictive probability under original Collins algorithm

Implements semantics::Marginal_cell_base.

Friends And Related Function Documentation

template<class T, size_t N>
std::ostream& operator ( std::ostream &  os,
const Map map 
)
friend

output a contingency table in human readable form to an ostream

Member Data Documentation

template<class T, size_t N>
Marginal_cell< T, N >::Map semantics::Marginal_cell< T, N >::map
static
template<class T, size_t N>
bool & semantics::Marginal_cell< T, N >::VERBOSE = Cell::VERBOSE
static

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