Quetzal-CoaTL
The Coalescence Template Library
Loading...
Searching...
No Matches
quetzal::coalescence::occupancy_spectrum::ProbabilityDistribution< FilterPolicy, EditorPolicy > Class Template Reference

#include <quetzal/coalescence/occupancy_spectrum/ProbabilityDistribution.hpp>

Detailed Description

template<class FilterPolicy = filter_policy::return_always_true, class EditorPolicy = editor_policy::identity>
class quetzal::coalescence::occupancy_spectrum::ProbabilityDistribution< FilterPolicy, EditorPolicy >

Occupancy spectrum distributed according to the probability function given by von Mises (1939).

Template Parameters
FilterPolicyFunction object class acting as a unary predicate, taking the probability of the spectrum as argument and returning a boolean. The signature should be bool FilterPolicy::operator()(double)
EditorPolicyPolicy class to edit the occupancy spectrum for optimal speed and memory usage. The class should expose a member with signature OccupancySpectrum EditorPolicy::edit(OccupancySpectrum &&).
Remarks
The probability of an occupancy spectrum is described in the book "Urn models and their application: an approach to modern discrete probability theory" (by John and Kotz, 1977, p.115).
The number of possible configurations grows very fast with \(n\) and \(m\), so memorizing all of them quickly becomes intractable. As most of the configurations have extremely low probability, you can choose to use a filter_policy class to filter the spectrum according to their sampling probability, keeping only those which probability is superior to a given threshold (or any other arbitrary criterion).
  • If the predicate is evaluated to true, the spectrum and its probability will be saved in the distribution.
  • If the predicate is evaluated to false, the spectrum and its probability will be discarded.
By default, the filter_policy::return_always_true filter policy is used, so all spectra are kept.
By default the editor_policy::identity policy is used and wil not modify the spectrum. The editor_policy::truncate_tail will remove all the last urns that are empty, making later iteration over a spectrum faster.

Public Member Functions

 ProbabilityDistribution ()=default
 Default constructor.
 
 ProbabilityDistribution (int n, int m, FilterPolicy pred=FilterPolicy())
 Construct the occupancy spectrum distribution resulting from throwing \(n\) balls into \(m\) urns.
 
 ProbabilityDistribution (const self_type &)=delete
 Copy constructor.
 
 ProbabilityDistribution (self_type &&)=default
 Move constructor.
 
self_typeoperator= (self_type &&)=default
 Move assignment operator.
 
self_typeoperator= (const self_type &)=delete
 Deleted copy assignment operator.
 
template<typename Generator >
const spectrum_typeoperator() (Generator &g) const
 Generates random occupancy spectrum that are distributed according to the associated probability function given by von Mises (1939).
 
int n () const
 The number of balls (coalescing lineages) that are thrown in the random experience.
 
int m () const
 The number of urns (parents) used in the random experience.
 
const support_type & support () const
 Get a constant reference on the support of occupancy spectrum distribution.
 
const probabilities_type & weights () const
 Get a constant reference the weights associated to each spectrum.
 

Static Public Member Functions

static double compute_probability (int n, int m, spectrum_type const &m_js)
 Computes the probability of a given spectrum for a given experiment.
 

Friends

std::ostream & operator<< (std::ostream &os, self_type const &dist)
 Stream operator to print the distribution support and probabilities.
 

Constructor & Destructor Documentation

◆ ProbabilityDistribution()

template<class FilterPolicy = filter_policy::return_always_true, class EditorPolicy = editor_policy::identity>
quetzal::coalescence::occupancy_spectrum::ProbabilityDistribution< FilterPolicy, EditorPolicy >::ProbabilityDistribution ( int  n,
int  m,
FilterPolicy  pred = FilterPolicy() 
)
inline

Construct the occupancy spectrum distribution resulting from throwing \(n\) balls into \(m\) urns.

Remarks
Object can be huge if large \(k\)
Parameters
nnumber of balls (lineages)
mnumber of urns (parents)
predA filter policy, that is a unary predicate

Member Function Documentation

◆ operator()()

template<class FilterPolicy = filter_policy::return_always_true, class EditorPolicy = editor_policy::identity>
template<typename Generator >
const spectrum_type & quetzal::coalescence::occupancy_spectrum::ProbabilityDistribution< FilterPolicy, EditorPolicy >::operator() ( Generator &  g) const
inline

Generates random occupancy spectrum that are distributed according to the associated probability function given by von Mises (1939).

Template Parameters
GeneratorA random number generator typename
Parameters
gThe random number generator.

◆ operator=()

template<class FilterPolicy = filter_policy::return_always_true, class EditorPolicy = editor_policy::identity>
self_type & quetzal::coalescence::occupancy_spectrum::ProbabilityDistribution< FilterPolicy, EditorPolicy >::operator= ( const self_type )
delete

Deleted copy assignment operator.

Remarks
Deleted for avoiding copying huge amount of data.

◆ weights()

template<class FilterPolicy = filter_policy::return_always_true, class EditorPolicy = editor_policy::identity>
const probabilities_type & quetzal::coalescence::occupancy_spectrum::ProbabilityDistribution< FilterPolicy, EditorPolicy >::weights ( ) const
inline

Get a constant reference the weights associated to each spectrum.

Remarks
As filters can be applied, weights do not necessarily sum to 1 before sampling.

Friends And Related Symbol Documentation

◆ operator<<

template<class FilterPolicy = filter_policy::return_always_true, class EditorPolicy = editor_policy::identity>
std::ostream & operator<< ( std::ostream &  os,
self_type const &  dist 
)
friend

Stream operator to print the distribution support and probabilities.

Remarks
As filters can be applied, weights do not necessarily sum to 1 before sampling.

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