Tree Compression with Top Trees Revisited
Public Member Functions | Friends | List of all members
EntropyCalculator< T, CounterType > Class Template Reference

Calculate entropy of a sequence of symbols. More...

#include <Entropy.h>

Public Member Functions

 EntropyCalculator ()
 Initialise entropy calculator. More...
 
void addItem (const T &item)
 
void addItem (T &&item)
 
template<class InputIterator >
void addSequence (InputIterator begin, InputIterator end)
 
size_t numSymbols () const
 The number of distinct symbols encountered. More...
 
CounterType numOccurences () const
 The number of occurences counted. More...
 
double getEntropy () const
 The entropy of a memoryless source using the symbol frequencies observed. More...
 
double optBitsForSymbol (const T &symbol) const
 
double optBitsForSymbol (T &&symbol) const
 
std::string summary () const
 A short string summary of the data collected. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const EntropyCalculator &entropy)
 

Detailed Description

template<typename T, typename CounterType = int>
class EntropyCalculator< T, CounterType >

Calculate entropy of a sequence of symbols.

Definition at line 15 of file Entropy.h.

Constructor & Destructor Documentation

template<typename T , typename CounterType = int>
EntropyCalculator< T, CounterType >::EntropyCalculator ( )
inline

Initialise entropy calculator.

Definition at line 18 of file Entropy.h.

Member Function Documentation

template<typename T , typename CounterType = int>
void EntropyCalculator< T, CounterType >::addItem ( const T &  item)
inline

add an occurence to the entropy calculation

Parameters
itemthe item to add, by const reference

Definition at line 22 of file Entropy.h.

template<typename T , typename CounterType = int>
void EntropyCalculator< T, CounterType >::addItem ( T &&  item)
inline

add an occurence to the entropy calculation

Parameters
itemthe item to add, by rvalue reference

Definition at line 30 of file Entropy.h.

template<typename T , typename CounterType = int>
template<class InputIterator >
void EntropyCalculator< T, CounterType >::addSequence ( InputIterator  begin,
InputIterator  end 
)
inline

Add a number of items [begin, end) to the entropy calculation

Parameters
beginiterator to the first item to add
endthe iterator to the item beyond the last one to add

Definition at line 40 of file Entropy.h.

template<typename T , typename CounterType = int>
double EntropyCalculator< T, CounterType >::getEntropy ( ) const
inline

The entropy of a memoryless source using the symbol frequencies observed.

Definition at line 57 of file Entropy.h.

template<typename T , typename CounterType = int>
CounterType EntropyCalculator< T, CounterType >::numOccurences ( ) const
inline

The number of occurences counted.

Definition at line 52 of file Entropy.h.

template<typename T , typename CounterType = int>
size_t EntropyCalculator< T, CounterType >::numSymbols ( ) const
inline

The number of distinct symbols encountered.

Definition at line 47 of file Entropy.h.

template<typename T , typename CounterType = int>
double EntropyCalculator< T, CounterType >::optBitsForSymbol ( const T &  symbol) const
inline

The optimal number of bits to code a symbol

Parameters
symbolthe symbol by const reference

Definition at line 69 of file Entropy.h.

template<typename T , typename CounterType = int>
double EntropyCalculator< T, CounterType >::optBitsForSymbol ( T &&  symbol) const
inline

The optimal number of bits to code a symbol

Parameters
symbolthe symbol by rvalue reference

Definition at line 77 of file Entropy.h.

template<typename T , typename CounterType = int>
std::string EntropyCalculator< T, CounterType >::summary ( ) const
inline

A short string summary of the data collected.

Definition at line 84 of file Entropy.h.

Friends And Related Function Documentation

template<typename T , typename CounterType = int>
std::ostream& operator<< ( std::ostream &  os,
const EntropyCalculator< T, CounterType > &  entropy 
)
friend

Definition at line 91 of file Entropy.h.


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