|
| | hmc (stan::model::prob_grad &model, double epsilon, int L, unsigned int random_seed=static_cast< unsigned int >(std::time(0))) |
| | Constructs a Hamiltonian Monte Carlo (HMC) sampler for the specified model, using the specified step size and number of leapfrog steps, with the specified random seed for randomization. More...
|
| |
| virtual | ~hmc () |
| | Destructor. More...
|
| |
| virtual void | set_params (const std::vector< double > &x, const std::vector< int > &z) |
| | Set the model real and integer parameters to the specified values. More...
|
| |
| virtual void | set_params_r (const std::vector< double > &x) |
| | Set the model real parameters to the specified values and update gradients and log probability to match. More...
|
| |
| virtual void | set_params_i (const std::vector< int > &z) |
| | Set the model real parameters to the specified values and update gradients and log probability to match. More...
|
| |
| virtual sample | next_impl () |
| | Return the next sample. More...
|
| |
| | adaptive_sampler (bool adapt, std::ostream *error_msgs=0, std::ostream *output_msgs=0) |
| | Constructs an adaptive sampler with specified adaptation status. More...
|
| |
| virtual | ~adaptive_sampler () |
| | Destructor. More...
|
| |
| void | set_error_stream (std::ostream &error_msgs) |
| | Set the stream into which errors will be written as the sampler runs. More...
|
| |
| void | unset_error_stream () |
| | Unset the stream into which errors are written to 0 so that error messages are ignored. More...
|
| |
| void | set_output_stream (std::ostream &output_msgs) |
| | Set the stream into which output will be written as the sampler runs. More...
|
| |
| void | unset_output_stream () |
| | Unset the stream into which errors are written to 0 so that output messages are ignored. More...
|
| |
| sample | next () |
| | Returns the next sample from this sampler. More...
|
| |
| virtual void | find_reasonable_parameters () |
| | Find a reasonable initial setting for the adaptable parameters. More...
|
| |
| virtual void | get_parameters (std::vector< double > ¶ms) |
| | Sets the specified parameter vector to the sequence of tunable parameters for this sampler. More...
|
| |
| double | mean_stat () |
| | Returns the value of the statistic we are trying to coerce. More...
|
| |
| void | set_mean_stat (double v) |
| | Sets the mean statistic to the specified value. More...
|
| |
| void | update_mean_stat (double avg_eta, double adapt_stat) |
| | Updates the mean statistic given the specified adaptation statistic and weighting. More...
|
| |
| unsigned int | nfevals () |
| | Returns the number of times that the (possibly unnormalized) log probability function has been evaluated by this sampler. More...
|
| |
| void | nfevals_plus_eq (int n) |
| | Add the specified number of evaluations to the number of function evaluations. More...
|
| |
| int | n_steps () |
| | Return the number of iterations for this sampler. More...
|
| |
| int | n_adapt_steps () |
| | Return how many iterations parameter adaptation has happened for. More...
|
| |
| virtual void | adapt_on () |
| | Turn on parameter adaptation. More...
|
| |
| virtual void | adapt_off () |
| | Turn off parameter adaption. More...
|
| |
| bool | adapting () |
| | Return whether or not parameter adaptation is on. More...
|
| |
| virtual void | write_sampler_params (std::ostream &o) |
| | Write out any sampler-specific parameters for output. More...
|
| |
| virtual void | write_adaptation_params (std::ostream &o) |
| | Use this method to write the adaptation parameters into the output. More...
|
| |
| virtual void | write_sampler_param_names (std::ostream &o) |
| | Write out any sampler-specific parameter names for output. More...
|
| |
| virtual void | get_sampler_param_names (std::vector< std::string > &names) |
| | Get any sampler-specific parameter namess. More...
|
| |
| virtual void | get_sampler_params (std::vector< double > &values) |
| | Get any sampler-specific parameters. More...
|
| |
Hamiltonian Monte Carlo (HMC) sampler.
The HMC sampler requires a probability model with the ability to compute gradients, characterized as an instance of prob_grad.
Samples from the sampler are returned through the base class sampler.
Definition at line 34 of file hmc.hpp.
| stan::mcmc::hmc::hmc |
( |
stan::model::prob_grad & |
model, |
|
|
double |
epsilon, |
|
|
int |
L, |
|
|
unsigned int |
random_seed = static_cast<unsigned int>(std::time(0)) |
|
) |
| |
|
inline |
Constructs a Hamiltonian Monte Carlo (HMC) sampler for the specified model, using the specified step size and number of leapfrog steps, with the specified random seed for randomization.
If the same seed is used twice, the series of samples should be the same. This property is most helpful for testing. If no random seed is specified, the std::time(0) function is called from the ctime library.
- Parameters
-
| model | Probability model with gradients. |
| epsilon | Hamiltonian dynamics simulation step size. |
| L | Number of leapfrog steps per simulation. |
| random_seed | Seed for random number generator; optional, if not specified, generate new seed based on system time. |
Definition at line 68 of file hmc.hpp.