Stan  1.0
probability, sampling & optimization
Public Member Functions | Protected Attributes | List of all members
stan::mcmc::DualAverage Class Reference

Implements Nesterov's dual average algorithm. More...

#include <dualaverage.hpp>

Public Member Functions

 DualAverage (double gamma, const std::vector< double > &x0)
 Constructor. More...
 
void update (const std::vector< double > &g, std::vector< double > &xk)
 Produces the next iterate xk given the current gradient g. More...
 
void setx0 (const std::vector< double > &x0)
 Set the point towards which each iterate is shrunk. More...
 
void xbar (std::vector< double > &xbar)
 Get the exponentially weighted moving average of all previous iterates. More...
 
void gbar (std::vector< double > &gbar)
 Get the average of all previous gradients. More...
 
void xk (std::vector< double > &xk)
 Get the current iterate. More...
 
void x0 (std::vector< double > &x0)
 Get the point towards which we're shrinking the iterates. More...
 
int k ()
 Return how many iterations we've run for. More...
 
double gamma ()
 Return the regularization parameter gamma. More...
 

Protected Attributes

std::vector< double > _gbar
 
std::vector< double > _xbar
 
std::vector< double > _x0
 
std::vector< double > _lastx
 
int _k
 
double _gamma
 

Detailed Description

Implements Nesterov's dual average algorithm.

Use by repeatedly calling update() with the gradient evaluated at xk(). When finished, use the average value of all the xk's by calling xbar().

Iterates are shrunk towards a prespecified point x0. The level of shrinkage is controlled by the parameter gamma and gets weaker with each iteration.

Note that this is an algorithm for MINIMIZATION, not MAXIMIZATION.

Definition at line 28 of file dualaverage.hpp.

Constructor & Destructor Documentation

◆ DualAverage()

stan::mcmc::DualAverage::DualAverage ( double  gamma,
const std::vector< double > &  x0 
)
inline

Constructor.

Parameters
gammaRegularization parameter. Higher values mean that iterates will be shrunk towards x0 more strongly.
x0Point towards which iterates are shrunk.

Definition at line 42 of file dualaverage.hpp.

Member Function Documentation

◆ gamma()

double stan::mcmc::DualAverage::gamma ( )
inline

Return the regularization parameter gamma.

Returns
the regularization parameter gamma.

Definition at line 125 of file dualaverage.hpp.

◆ gbar()

void stan::mcmc::DualAverage::gbar ( std::vector< double > &  gbar)
inline

Get the average of all previous gradients.

Parameters
[out]gbarWhere to return the average of all previous gradients.

Definition at line 94 of file dualaverage.hpp.

◆ k()

int stan::mcmc::DualAverage::k ( )
inline

Return how many iterations we've run for.

Returns
how many iterations we've run for.

Definition at line 119 of file dualaverage.hpp.

◆ setx0()

void stan::mcmc::DualAverage::setx0 ( const std::vector< double > &  x0)
inline

Set the point towards which each iterate is shrunk.

Parameters
x0The point towards each iterate will be shrunk.

Definition at line 75 of file dualaverage.hpp.

◆ update()

void stan::mcmc::DualAverage::update ( const std::vector< double > &  g,
std::vector< double > &  xk 
)
inline

Produces the next iterate xk given the current gradient g.

Parameters
[in]gThe new subgradient/stochastic gradient.
[out]xkThe next iterate produced by the algorithm.

Definition at line 53 of file dualaverage.hpp.

◆ x0()

void stan::mcmc::DualAverage::x0 ( std::vector< double > &  x0)
inline

Get the point towards which we're shrinking the iterates.

Parameters
x0Where to return the point towards which we're shrinking the iterates.

Definition at line 111 of file dualaverage.hpp.

◆ xbar()

void stan::mcmc::DualAverage::xbar ( std::vector< double > &  xbar)
inline

Get the exponentially weighted moving average of all previous iterates.

Parameters
[out]xbarWhere to return the exponentially weighted moving average of all previous iterates.

Definition at line 86 of file dualaverage.hpp.

◆ xk()

void stan::mcmc::DualAverage::xk ( std::vector< double > &  xk)
inline

Get the current iterate.

Parameters
[out]xkWhere to return the current iterate.

Definition at line 102 of file dualaverage.hpp.

Member Data Documentation

◆ _gamma

double stan::mcmc::DualAverage::_gamma
protected

Definition at line 32 of file dualaverage.hpp.

◆ _gbar

std::vector<double> stan::mcmc::DualAverage::_gbar
protected

Definition at line 30 of file dualaverage.hpp.

◆ _k

int stan::mcmc::DualAverage::_k
protected

Definition at line 31 of file dualaverage.hpp.

◆ _lastx

std::vector<double> stan::mcmc::DualAverage::_lastx
protected

Definition at line 30 of file dualaverage.hpp.

◆ _x0

std::vector<double> stan::mcmc::DualAverage::_x0
protected

Definition at line 30 of file dualaverage.hpp.

◆ _xbar

std::vector<double> stan::mcmc::DualAverage::_xbar
protected

Definition at line 30 of file dualaverage.hpp.


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

     [ Stan Home Page ] © 2011–2012, Stan Development Team.