Particle Population

Class used to store and manipulate the population of particles.

This file contains the smc::population class which is used internally.

Defines

__SMC_POPULATION_HH
namespace smc

The Sequential Monte Carlo namespace.

The classes and functions within this namespace are intended to be used for producing implemenetations of SMC samplers and related simulation techniques.

Functions

inline double stableLogSumWeights(const arma::vec &logw)

A stable calculation of the log sum of the weights, used in ESS calculations This function performs a stable calculation of the log sum of the weights, which is useful for normalising weights, calculating the effective sample size and estimating the normalising constant.

Parameters

logw – The log weights of interest.

template<class Space>
class population
#include <population.h>

A template class for the particles of an SMC algorithm.

Public Functions

population()

Create a particle with undefined values and weights.

population(const std::vector<Space> &sInit, const arma::vec &dLogWeight)

Constructor which initialises the particle values and weights.

Create particles with values sInit and log weights dLogWeight

Parameters
  • sInit – The initial values of the particle

  • dLogWeight – The initial values of the natural logarithm of the particle weights

population(const population<Space> &pFrom)

The copy constructor performs a shallow copy.

Copy constructor.

population<Space> &operator=(const population<Space> &pFrom)

The assignment operator performs a shallow copy.

Copy the values of pFrom to the values of this to set this population identical to pFrom in a deep copy sense.

~population()

Dispose of a population object which is no longer required.

inline long GetNumber(void) const

Returns the number of particles within the system.

inline const std::vector<Space> &GetValue(void) const

Returns the particle values.

inline const Space &GetValueN(long n) const

Returns the value of the nth particle in the population.

inline Space &GetValueRefN(long n)

Returns a reference to the value of the nth particle in the population.

inline const arma::vec &GetLogWeight(void) const

Returns the particle log weights.

inline double GetLogWeightN(long n) const

Returns the nth particle’s log weight.

inline double &GetLogWeightRefN(long n)

Returns a reference to the nth particle’s log weight.

inline arma::vec GetWeight(void) const

Returns the particles’ unnormalised weights.

inline double GetWeightN(long n) const

Returns the nth particle’s unnormalised weight.

inline void Set(const std::vector<Space> &sValue, const arma::vec &dLogWeight)

Sets the particle values and weights explicitly.

Parameters
  • sValue – The particle values to use

  • dLogWeight – The natural logarithm of the new particle weights

inline void SetValue(const std::vector<Space> &sValue)

Sets the particle values explicitly.

Parameters

sValue – The particle values to use

inline void SetValueN(const Space &sValue, long n)

Sets the nth particle value explicitly.

Parameters

sValue – The particle value to use

inline void SetLogWeight(const arma::vec &dLogWeight)

Sets the particle log weights explicitly.

Parameters

dLogWeight – The natural logarithm of the new particle weights to use

inline void SetLogWeightN(const double &dLogWeight, long n)

Sets the nth particle log weight explicitly.

Parameters

dLogWeight – The natural logarithm of the new particle weight to use

Private Members

std::vector<Space> value

Values of the particles.

arma::vec logweight

Natural logarithm of the particle weights.

namespace std

The standard namespace.

The classes provided within the standard libraries reside within this namespace and the TDSMC class library adds a number of additional operator overloads to some of the standard classes to allow them to deal with our structures.

Functions

template<class Space>
std::ostream &operator<<(std::ostream &os, smc::population<Space> &p)

Produce a human readable display of an smc::population class using the standard stream operators.

Parameters
  • os – The output stream to which the display should be made.

  • p – The population object which is to be displayed.