Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Namespaces | Classes | Functions
stan::common Namespace Reference

Namespaces

 recorder
 

Classes

struct  NoOpFunctor
 
class  var_context_factory
 
class  dump_factory
 

Functions

template<class Model >
int command (int argc, const char *argv[])
 
template<typename ModelT , typename BFGSOptimizerT , typename RNGT , typename StartIterationCallback >
int do_bfgs_optimize (ModelT &model, BFGSOptimizerT &bfgs, RNGT &base_rng, double &lp, std::vector< double > &cont_vector, std::vector< int > &disc_vector, std::fstream *output_stream, std::ostream *notice_stream, bool save_iterations, int refresh, StartIterationCallback &callback)
 
bool do_print (const int n, const bool special, const int refresh)
 Indicates whether it should print on the current iteration. More...
 
bool do_print (const int n, const int refresh)
 Indicates whether it should print on the current iteration. More...
 
template<class Sampler >
bool init_adapt (Sampler *sampler, const double delta, const double gamma, const double kappa, const double t0, const Eigen::VectorXd &cont_params)
 
template<class Sampler >
bool init_adapt (stan::mcmc::base_mcmc *sampler, stan::gm::categorical_argument *adapt, const Eigen::VectorXd &cont_params)
 
template<class Sampler >
bool init_nuts (stan::mcmc::base_mcmc *sampler, stan::gm::argument *algorithm)
 
template<class Sampler >
bool init_static_hmc (stan::mcmc::base_mcmc *sampler, stan::gm::argument *algorithm)
 
template<class Sampler >
bool init_windowed_adapt (stan::mcmc::base_mcmc *sampler, stan::gm::categorical_argument *adapt, unsigned int num_warmup, const Eigen::VectorXd &cont_params)
 
template<class Model >
bool initialize_state_zero (Eigen::VectorXd &cont_params, Model &model, std::ostream *output)
 Sets initial state to zero. More...
 
template<class Model , class RNG >
bool initialize_state_random (const double R, Eigen::VectorXd &cont_params, Model &model, RNG &base_rng, std::ostream *output)
 Initializes state to random uniform values within range. More...
 
template<class ContextFactory , class Model , class RNG >
bool initialize_state_source (const std::string source, Eigen::VectorXd &cont_params, Model &model, RNG &base_rng, std::ostream *output, ContextFactory &context_factory)
 Creates the initial state using the source parameter. More...
 
bool get_double_from_string (const std::string &s, double &val)
 Converts string to double. More...
 
template<class ContextFactory , class Model , class RNG >
bool initialize_state (const std::string init, Eigen::VectorXd &cont_params, Model &model, RNG &base_rng, std::ostream *output, ContextFactory &context_factory)
 Creates the initial state. More...
 
void print_progress (const int m, const int start, const int finish, const int refresh, const bool warmup, const std::string prefix, const std::string suffix, std::ostream &o)
 
template<class Model , class RNG , class StartTransitionCallback , class SampleRecorder , class DiagnosticRecorder , class MessageRecorder >
void run_markov_chain (stan::mcmc::base_mcmc *sampler, const int num_iterations, const int start, const int finish, const int num_thin, const int refresh, const bool save, const bool warmup, stan::io::mcmc_writer< Model, SampleRecorder, DiagnosticRecorder, MessageRecorder > &writer, stan::mcmc::sample &init_s, Model &model, RNG &base_rng, const std::string &prefix, const std::string &suffix, std::ostream &o, StartTransitionCallback &callback)
 
template<class Model , class RNG , class StartTransitionCallback , class SampleRecorder , class DiagnosticRecorder , class MessageRecorder >
void sample (stan::mcmc::base_mcmc *sampler, int num_warmup, int num_samples, int num_thin, int refresh, bool save, stan::io::mcmc_writer< Model, SampleRecorder, DiagnosticRecorder, MessageRecorder > &writer, stan::mcmc::sample &init_s, Model &model, RNG &base_rng, const std::string &prefix, const std::string &suffix, std::ostream &o, StartTransitionCallback &callback)
 
template<class Model , class RNG , class StartTransitionCallback , class SampleRecorder , class DiagnosticRecorder , class MessageRecorder >
void warmup (stan::mcmc::base_mcmc *sampler, int num_warmup, int num_samples, int num_thin, int refresh, bool save, stan::io::mcmc_writer< Model, SampleRecorder, DiagnosticRecorder, MessageRecorder > &writer, stan::mcmc::sample &init_s, Model &model, RNG &base_rng, const std::string &prefix, const std::string &suffix, std::ostream &o, StartTransitionCallback &callback)
 
void write_error_msg (std::ostream *error_stream, const std::exception &e)
 
template<class Model , class RNG >
void write_iteration (std::ostream &output_stream, Model &model, RNG &base_rng, double lp, std::vector< double > &cont_vector, std::vector< int > &disc_vector)
 
void write_iteration_csv (std::ostream &output_stream, const double lp, const std::vector< double > &model_values)
 
void write_model (std::ostream *s, const std::string model_name, const std::string prefix="")
 
void write_stan (std::ostream *s, const std::string prefix="")
 

Function Documentation

template<class Model >
int stan::common::command ( int  argc,
const char *  argv[] 
)

Definition at line 67 of file command.hpp.

template<typename ModelT , typename BFGSOptimizerT , typename RNGT , typename StartIterationCallback >
int stan::common::do_bfgs_optimize ( ModelT &  model,
BFGSOptimizerT &  bfgs,
RNGT &  base_rng,
double &  lp,
std::vector< double > &  cont_vector,
std::vector< int > &  disc_vector,
std::fstream *  output_stream,
std::ostream *  notice_stream,
bool  save_iterations,
int  refresh,
StartIterationCallback &  callback 
)

Definition at line 21 of file do_bfgs_optimize.hpp.

bool stan::common::do_print ( const int  n,
const bool  special,
const int  refresh 
)

Indicates whether it should print on the current iteration.

The function returns: true if refresh > 0 and (n == 0 or (n + 1) % refresh == 0 or special == true) false otherwise. Examples: if refresh = 0, always returns false. if refresh = 10 and special == false, returns true for n = {0, 9, 19, ...}, returns false for n = {1 - 8, 10 - 18, 20 - 28, ...}. if refresh = 10 and special == true, returns true for all n.

Parameters
nIteration number
specialWhen true, returns true
refreshNumber of iterations to refresh

Definition at line 25 of file do_print.hpp.

bool stan::common::do_print ( const int  n,
const int  refresh 
)

Indicates whether it should print on the current iteration.

The function returns: true if refresh > 0 and (n == 0 or (n + 1) % refresh == 0) false otherwise. Examples: if refresh = 0, always returns false. if refresh = 10, returns true for n = {0, 9, 19, ...}, returns false for n = {1 - 8, 10 - 18, 20 - 28, ...}.

Parameters
nIteration number
refreshNumber of iterations to refresh

Definition at line 43 of file do_print.hpp.

bool stan::common::get_double_from_string ( const std::string &  s,
double &  val 
)

Converts string to double.

Returns true if it is able to convert the number, false otherwise.

Parameters
[in]sstring input
[out]valthe double value of the string if it is parsable as a double; else NaN

Definition at line 208 of file initialize_state.hpp.

template<class Sampler >
bool stan::common::init_adapt ( Sampler *  sampler,
const double  delta,
const double  gamma,
const double  kappa,
const double  t0,
const Eigen::VectorXd &  cont_params 
)

Definition at line 13 of file init_adapt.hpp.

template<class Sampler >
bool stan::common::init_adapt ( stan::mcmc::base_mcmc sampler,
stan::gm::categorical_argument adapt,
const Eigen::VectorXd &  cont_params 
)

Definition at line 42 of file init_adapt.hpp.

template<class Sampler >
bool stan::common::init_nuts ( stan::mcmc::base_mcmc sampler,
stan::gm::argument algorithm 
)

Definition at line 13 of file init_nuts.hpp.

template<class Sampler >
bool stan::common::init_static_hmc ( stan::mcmc::base_mcmc sampler,
stan::gm::argument algorithm 
)

Definition at line 13 of file init_static_hmc.hpp.

template<class Sampler >
bool stan::common::init_windowed_adapt ( stan::mcmc::base_mcmc sampler,
stan::gm::categorical_argument adapt,
unsigned int  num_warmup,
const Eigen::VectorXd &  cont_params 
)

Definition at line 13 of file init_windowed_adapt.hpp.

template<class ContextFactory , class Model , class RNG >
bool stan::common::initialize_state ( const std::string  init,
Eigen::VectorXd &  cont_params,
Model &  model,
RNG &  base_rng,
std::ostream *  output,
ContextFactory &  context_factory 
)

Creates the initial state.

Parameters
[in]initinit can either be "0", a number as a string, or a filename.
[out]cont_paramsthe initialized state. This should be the right size and set to 0.
[in,out]modelthe model. Side effects on model? I'm not quite sure
[in,out]base_rngthe random number generator. State may change.
[in,out]outputoutput stream for messages
[in,out]context_factoryan instantiated factory that implements the concept of a context_factory. This has one method that takes a string.

Definition at line 234 of file initialize_state.hpp.

template<class Model , class RNG >
bool stan::common::initialize_state_random ( const double  R,
Eigen::VectorXd &  cont_params,
Model &  model,
RNG &  base_rng,
std::ostream *  output 
)

Initializes state to random uniform values within range.

Parameters
[in]Rvalid range of the initialization; must be greater than or equal to 0.
[out]cont_paramsthe initialized state. This should be the right size and set to 0.
[in,out]modelthe model. Side effects on model? I'm not quite sure
[in,out]base_rngthe random number generator. State may change.
[in,out]outputoutput stream for messages

Definition at line 82 of file initialize_state.hpp.

template<class ContextFactory , class Model , class RNG >
bool stan::common::initialize_state_source ( const std::string  source,
Eigen::VectorXd &  cont_params,
Model &  model,
RNG &  base_rng,
std::ostream *  output,
ContextFactory &  context_factory 
)

Creates the initial state using the source parameter.

Parameters
[in]sourcea string that the context_factory can interpret and provide a valid var_context
[out]cont_paramsthe initialized state. This should be the right size and set to 0.
[in,out]modelthe model. Side effects on model? I'm not quite sure
[in,out]base_rngthe random number generator. State may change.
[in,out]outputoutput stream for messages
[in,out]context_factoryan instantiated factory that implements the concept of a context_factory. This has one method that takes a string.

Definition at line 154 of file initialize_state.hpp.

template<class Model >
bool stan::common::initialize_state_zero ( Eigen::VectorXd &  cont_params,
Model &  model,
std::ostream *  output 
)

Sets initial state to zero.

Parameters
[out]cont_paramsthe initialized state. This should be the right size and set to 0.
[in,out]modelthe model. Side effects on model? I'm not quite sure
[in,out]outputoutput stream for messages

Definition at line 33 of file initialize_state.hpp.

void stan::common::print_progress ( const int  m,
const int  start,
const int  finish,
const int  refresh,
const bool  warmup,
const std::string  prefix,
const std::string  suffix,
std::ostream &  o 
)

Definition at line 13 of file print_progress.hpp.

template<class Model , class RNG , class StartTransitionCallback , class SampleRecorder , class DiagnosticRecorder , class MessageRecorder >
void stan::common::run_markov_chain ( stan::mcmc::base_mcmc sampler,
const int  num_iterations,
const int  start,
const int  finish,
const int  num_thin,
const int  refresh,
const bool  save,
const bool  warmup,
stan::io::mcmc_writer< Model, SampleRecorder, DiagnosticRecorder, MessageRecorder > &  writer,
stan::mcmc::sample init_s,
Model &  model,
RNG &  base_rng,
const std::string &  prefix,
const std::string &  suffix,
std::ostream &  o,
StartTransitionCallback &  callback 
)

Definition at line 13 of file run_markov_chain.hpp.

template<class Model , class RNG , class StartTransitionCallback , class SampleRecorder , class DiagnosticRecorder , class MessageRecorder >
void stan::common::sample ( stan::mcmc::base_mcmc sampler,
int  num_warmup,
int  num_samples,
int  num_thin,
int  refresh,
bool  save,
stan::io::mcmc_writer< Model, SampleRecorder, DiagnosticRecorder, MessageRecorder > &  writer,
stan::mcmc::sample init_s,
Model &  model,
RNG &  base_rng,
const std::string &  prefix,
const std::string &  suffix,
std::ostream &  o,
StartTransitionCallback &  callback 
)

Definition at line 13 of file sample.hpp.

template<class Model , class RNG , class StartTransitionCallback , class SampleRecorder , class DiagnosticRecorder , class MessageRecorder >
void stan::common::warmup ( stan::mcmc::base_mcmc sampler,
int  num_warmup,
int  num_samples,
int  num_thin,
int  refresh,
bool  save,
stan::io::mcmc_writer< Model, SampleRecorder, DiagnosticRecorder, MessageRecorder > &  writer,
stan::mcmc::sample init_s,
Model &  model,
RNG &  base_rng,
const std::string &  prefix,
const std::string &  suffix,
std::ostream &  o,
StartTransitionCallback &  callback 
)

Definition at line 13 of file warmup.hpp.

void stan::common::write_error_msg ( std::ostream *  error_stream,
const std::exception &  e 
)

Definition at line 11 of file write_error_msg.hpp.

template<class Model , class RNG >
void stan::common::write_iteration ( std::ostream &  output_stream,
Model &  model,
RNG &  base_rng,
double  lp,
std::vector< double > &  cont_vector,
std::vector< int > &  disc_vector 
)

Definition at line 19 of file write_iteration.hpp.

void stan::common::write_iteration_csv ( std::ostream &  output_stream,
const double  lp,
const std::vector< double > &  model_values 
)

Definition at line 10 of file write_iteration_csv.hpp.

void stan::common::write_model ( std::ostream *  s,
const std::string  model_name,
const std::string  prefix = "" 
)

Definition at line 11 of file write_model.hpp.

void stan::common::write_stan ( std::ostream *  s,
const std::string  prefix = "" 
)

Definition at line 12 of file write_stan.hpp.


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