Fleet  0.0.9
Inference in the LOT
Public Types | Public Member Functions | Public Attributes | List of all members
DiscreteDistribution< T > Class Template Reference

#include <DiscreteDistribution.h>

Public Types

using my_map_t = typename std::conditional< std::is_same< T, double >::value or std::is_same< T, float >::value, std::map< T, double, floating_point_compare< double > >, std::map< T, double > >::type
 

Public Member Functions

 DiscreteDistribution ()
 
virtual T argmax () const
 
void print (std::ostream &out, unsigned long nprint=0) const
 
void print (unsigned long nprint=0) const
 
void erase (const T &k)
 
std::string string (unsigned long nprint=0) const
 
void addmass (T x, double v)
 
double get (T x, double v) const
 
const std::map< T, double > & values () const
 
void operator<< (const DiscreteDistribution< T > &x)
 
double Z () const
 
double lp (const T &x)
 
std::vector< T > best (size_t n, bool include_equal) const
 
std::vector< std::pair< T, double > > sorted (bool decreasing=false) const
 
size_t count (T x) const
 
size_t size () const
 
double operator[] (const T x)
 
double at (T x) const
 
bool operator< (const DiscreteDistribution< T > &x) const
 This compares using just a standard ordering on keys – mainly here so we can put DiscreteDistributions in maps. More...
 

Public Attributes

my_map_t m
 

Detailed Description

template<typename T>
class DiscreteDistribution< T >

Author
steven piantadosi
Date
03/02/20

Member Typedef Documentation

◆ my_map_t

template<typename T>
using DiscreteDistribution< T >::my_map_t = typename std::conditional< std::is_same<T,double>::value or std::is_same<T,float>::value, std::map<T,double,floating_point_compare<double> >, std::map<T,double> >::type

Constructor & Destructor Documentation

◆ DiscreteDistribution()

template<typename T>
DiscreteDistribution< T >::DiscreteDistribution ( )
inline

Member Function Documentation

◆ addmass()

template<typename T>
void DiscreteDistribution< T >::addmass ( x,
double  v 
)
inline

Add log probability v to type x

Parameters
x
v

◆ argmax()

template<typename T>
virtual T DiscreteDistribution< T >::argmax ( ) const
inlinevirtual

◆ at()

template<typename T>
double DiscreteDistribution< T >::at ( x) const
inline

◆ best()

template<typename T>
std::vector<T> DiscreteDistribution< T >::best ( size_t  n,
bool  include_equal 
) const
inline

Get the N best from this distribution

Parameters
N- how many to get
include_equal- should we include ones that are equal to the best (potentially giving more than N)?
Returns

◆ count()

template<typename T>
size_t DiscreteDistribution< T >::count ( x) const
inline

◆ erase()

template<typename T>
void DiscreteDistribution< T >::erase ( const T &  k)
inline

◆ get()

template<typename T>
double DiscreteDistribution< T >::get ( x,
double  v 
) const
inline

◆ lp()

template<typename T>
double DiscreteDistribution< T >::lp ( const T &  x)
inline

Retun the log probability of x, including the normalizing term (NOTE: This makes this O(N) to compute theo normalizer. So this is bad to use if you have to iterate over the set – you shoul call Z() separately then

Parameters
N
Returns

◆ operator<()

template<typename T>
bool DiscreteDistribution< T >::operator< ( const DiscreteDistribution< T > &  x) const
inline

This compares using just a standard ordering on keys – mainly here so we can put DiscreteDistributions in maps.

Parameters
x
Returns

◆ operator<<()

template<typename T>
void DiscreteDistribution< T >::operator<< ( const DiscreteDistribution< T > &  x)
inline

◆ operator[]()

template<typename T>
double DiscreteDistribution< T >::operator[] ( const T  x)
inline

◆ print() [1/2]

template<typename T>
void DiscreteDistribution< T >::print ( std::ostream &  out,
unsigned long  nprint = 0 
) const
inline

◆ print() [2/2]

template<typename T>
void DiscreteDistribution< T >::print ( unsigned long  nprint = 0) const
inline

◆ size()

template<typename T>
size_t DiscreteDistribution< T >::size ( ) const
inline

◆ sorted()

template<typename T>
std::vector<std::pair<T,double> > DiscreteDistribution< T >::sorted ( bool  decreasing = false) const
inline

Get this distribution as a sorted vector of pairs

Parameters
decreasing

◆ string()

template<typename T>
std::string DiscreteDistribution< T >::string ( unsigned long  nprint = 0) const
inline

Convert this distribution into a string, printing at most nprint

Parameters
nprint
Returns

◆ values()

template<typename T>
const std::map<T,double>& DiscreteDistribution< T >::values ( ) const
inline

Get all of the values in this distribution

Returns

◆ Z()

template<typename T>
double DiscreteDistribution< T >::Z ( ) const
inline

Member Data Documentation

◆ m

template<typename T>
my_map_t DiscreteDistribution< T >::m

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