Stan  1.0
probability, sampling & optimization
Public Member Functions | List of all members
stan::mcmc::chains< RNG > Class Template Reference

An mcmc::chains object stores parameter names and dimensionalities along with samples from multiple chains. More...

#include <chains.hpp>

Public Member Functions

 chains (const size_t num_chains, const std::vector< std::string > &names, const std::vector< std::vector< size_t > > &dimss)
 Construct a chains object with the specified number of Markov chains, and the specified parameter names and matching parameter dimensions. More...
 
size_t num_chains ()
 Return the number of chains. More...
 
size_t num_params ()
 Return the total number of parameters. More...
 
size_t num_param_names ()
 Return the total number of parameter names. More...
 
const std::vector< std::string > & param_names ()
 Return the sequence of parameter names. More...
 
const std::string & param_name (size_t j)
 Return the name of the parameter with the specified index. More...
 
const std::vector< std::vector< size_t > > & param_dimss ()
 Return the sequence of named parameter dimensions. More...
 
const std::vector< size_t > & param_dims (size_t j)
 Return the dimensions of the parameter name with the specified index. More...
 
const std::vector< size_t > & param_starts ()
 Return the sequence of starting indexes for the named parameters in the underlying sequence of scalar parameters. More...
 
size_t param_start (size_t j)
 Return the starting position of the named parameter with the specified index in the underlying sequence of scalar parameters. More...
 
const std::vector< size_t > param_sizes ()
 Return a copy of the sequence of named parameter sizes. More...
 
size_t param_size (size_t j)
 Return the size of the named parameter with the specified index. More...
 
size_t param_name_to_index (const std::string &name)
 Return the named parameter index for the specified parameter name. More...
 
size_t get_total_param_index (size_t j, const std::vector< size_t > &idxs)
 Return the index in the underlying sequence of scalar parameters for the parameter with the specified name index and indexes. More...
 
void set_warmup (size_t warmup_iterations)
 Set the warmup cutoff to the specified number of iterations. More...
 
size_t warmup ()
 Return the warmup iteration cutoff. More...
 
void add (size_t chain, std::vector< double > theta)
 Add the specified sample to the end of the specified chain. More...
 
size_t num_warmup_samples (size_t k)
 Return the number of warmup samples in the specified chain. More...
 
size_t num_warmup_samples ()
 Return the total number of warmup samples across chains. More...
 
size_t num_kept_samples (size_t k)
 Return the number of samples in the specified chain not including warmup samples. More...
 
size_t num_kept_samples ()
 Return the total number of samples in all chains not including warmup samples. More...
 
size_t num_samples ()
 Return the total number of samples across chains including warmup and kept samples. More...
 
size_t num_samples (size_t k)
 Return the number of samples including warmup and kept samples in the specified chain. More...
 
void get_samples (size_t n, std::vector< double > &samples)
 Write into the specified vector the warmup and kept samples for the scalar parameter with the specified index. More...
 
void get_samples (size_t k, size_t n, std::vector< double > &samples)
 Write into the specified vector the warmup and kept samples for the scalar parameter with the specified index in the chain with the specified index. More...
 
void get_kept_samples_permuted (size_t n, std::vector< double > &samples)
 Write into the specified vector the kept samples for the scalar parameter with the specified index. More...
 
template<typename F >
void apply_kept_samples (size_t k, size_t n, F &f)
 Apply the specified functor to each kept sample for the specified parameter in the specified chain. More...
 
template<typename F >
void apply_kept_samples (size_t n, F &f)
 Apply the specified functor to each kept sample for the specified parameter across all chains. More...
 
void get_kept_samples (size_t k, size_t n, std::vector< double > &samples)
 Write into the specified vector the kept samples for the scalar parameter with the specified index in the chain with the specified index. More...
 
void get_warmup_samples (size_t n, std::vector< double > &samples)
 Write into the specified vector the warmup samples for the scalar parameter with the specified index. More...
 
void get_warmup_samples (size_t k, size_t n, std::vector< double > &samples)
 Write into the specified vector the warmup samples for the parameter with the specified index in the chain with the specified index. More...
 
double mean (size_t k, size_t n)
 Return the sample mean of the kept samples in the specified chain for the specified parameter. More...
 
double mean (size_t n)
 Return the sample mean of the kept samples in all chains for the specified parameter. More...
 
double sd (size_t k, size_t n)
 Return the sample standard deviation of the kept samples in the specified chain for the specified parameter. More...
 
double sd (size_t n)
 Return the sample standard deviation of the kept samples in all chains for the specified parameter. More...
 
double variance (size_t k, size_t n)
 Return the variance of the kept samples in the specified chain for the specified parameter. More...
 
double variance (size_t n)
 Return the variance of the kept samples in all chains for the specified parameter. More...
 
double covariance (size_t k, size_t n1, size_t n2)
 Return the covariance of the kept samples in the specified chain for the specified parameters. More...
 
double covariance (size_t n1, size_t n2)
 Return the covariance of the kept samples for the specified parameters. More...
 
double correlation (size_t k, size_t n1, size_t n2)
 Return the correlation of the kept samples in the specified chain for the specified parameters. More...
 
double correlation (size_t n1, size_t n2)
 Return the correlation of the kept samples for the specified parameters. More...
 
double quantile (size_t k, size_t n, double prob)
 Return the specified sample quantile for kept samples for the specified parameter in the specified chain. More...
 
double quantile (size_t n, double prob)
 Return the specified sample quantile for kept samples for the specified parameter across all chains. More...
 
void quantiles (size_t k, size_t n, const std::vector< double > &probs, std::vector< double > &quantiles)
 Write the specified sample quantiles into the specified vector for the kept samples for the specified parameter in the specified chain. More...
 
void quantiles (size_t n, const std::vector< double > &probs, std::vector< double > &quantiles)
 Write the specified sample quantiles into the specified vector for the kept samples for the specified parameter across all chains. More...
 
std::pair< double, double > central_interval (size_t k, size_t n, double prob)
 Return the specified sample central interval for the specified parameter in the kept samples in the specified chain. More...
 
std::pair< double, double > central_interval (size_t n, double prob)
 Return the specified central interval for the specified parameter in the kept samples of all chains. More...
 
void autocorrelation (const size_t k, const size_t n, std::vector< double > &ac)
 Returns the autocorrelations for the specified parameter in the kept samples of the chain specified. More...
 
void autocovariance (const size_t k, const size_t n, std::vector< double > &acov)
 Returns the autocovariance for the specified parameter in the kept samples of the chain specified. More...
 
double effective_sample_size (size_t n)
 Returns the effective sample size for the specified parameter across all kept samples. More...
 
double split_potential_scale_reduction (size_t n)
 Return the split potential scale reduction (split R hat) for the specified parameter. More...
 

Detailed Description

template<typename RNG = boost::random::ecuyer1988>
class stan::mcmc::chains< RNG >

An mcmc::chains object stores parameter names and dimensionalities along with samples from multiple chains.

Synchronization: For arbitrary concurrent use, the read and write methods need to be read/write locked. Multiple writers can be used concurrently if they write to different chains. Readers for single chains need only be read/write locked with writers of that chain. For reading across chains, full read/write locking is required. Thus methods will be classified as global or single-chain read or write methods.

Storage Order: Storage is column/last-index major.

Definition at line 234 of file chains.hpp.

Constructor & Destructor Documentation

◆ chains()

template<typename RNG = boost::random::ecuyer1988>
stan::mcmc::chains< RNG >::chains ( const size_t  num_chains,
const std::vector< std::string > &  names,
const std::vector< std::vector< size_t > > &  dimss 
)
inline

Construct a chains object with the specified number of Markov chains, and the specified parameter names and matching parameter dimensions.

The order of the parameter names and dimesnions should match the order in which samples are added to the constructed object.

The total number of parameters is determined by adding the parameters for each name. The number of parameters for each name is determined by multiplying its dimensionalities. For example, a 2 x 3 x 4 matrix parameter produces of 24 total parameters.

Parameters
num_chainsNumber of Markov chains.
namesSequence of paramter names.
dimssSequence of parameter dimensionalities.
Exceptions
std::invalid_argumentIf the name and dimensions sequences are not the same size.

Definition at line 351 of file chains.hpp.

Member Function Documentation

◆ add()

template<typename RNG = boost::random::ecuyer1988>
void stan::mcmc::chains< RNG >::add ( size_t  chain,
std::vector< double >  theta 
)
inline

Add the specified sample to the end of the specified chain.

Synchronization: Chain-specific write.

Parameters
chainMarkov chain identifier.
thetaParameter values.
Exceptions
std::invalid_argumentif the size of the sample vector does not match the number of parameters.

Definition at line 595 of file chains.hpp.

◆ apply_kept_samples() [1/2]

template<typename RNG = boost::random::ecuyer1988>
template<typename F >
void stan::mcmc::chains< RNG >::apply_kept_samples ( size_t  k,
size_t  n,
F &  f 
)
inline

Apply the specified functor to each kept sample for the specified parameter in the specified chain.

The samples are visited in the order they were added.

Template Parameters
FType of functor to apply
Parameters
kChain index
nParameter index
fFunctor to apply to kept samples

Definition at line 800 of file chains.hpp.

◆ apply_kept_samples() [2/2]

template<typename RNG = boost::random::ecuyer1988>
template<typename F >
void stan::mcmc::chains< RNG >::apply_kept_samples ( size_t  n,
F &  f 
)
inline

Apply the specified functor to each kept sample for the specified parameter across all chains.

The samples are visited in the order of chain index, and within a chain, in the order they were added.

Template Parameters
FType of functor to apply
Parameters
nParameter index
fFunctor to apply to kept samples

Definition at line 822 of file chains.hpp.

◆ autocorrelation()

template<typename RNG = boost::random::ecuyer1988>
void stan::mcmc::chains< RNG >::autocorrelation ( const size_t  k,
const size_t  n,
std::vector< double > &  ac 
)
inline

Returns the autocorrelations for the specified parameter in the kept samples of the chain specified.

Parameters
[in]kChain index
[in]nParameter index
[out]acAutocorrelations

Definition at line 1388 of file chains.hpp.

◆ autocovariance()

template<typename RNG = boost::random::ecuyer1988>
void stan::mcmc::chains< RNG >::autocovariance ( const size_t  k,
const size_t  n,
std::vector< double > &  acov 
)
inline

Returns the autocovariance for the specified parameter in the kept samples of the chain specified.

Parameters
[in]kChain index
[in]nParameter index
[out]acovAutocovariances

Definition at line 1404 of file chains.hpp.

◆ central_interval() [1/2]

template<typename RNG = boost::random::ecuyer1988>
std::pair<double,double> stan::mcmc::chains< RNG >::central_interval ( size_t  k,
size_t  n,
double  prob 
)
inline

Return the specified sample central interval for the specified parameter in the kept samples in the specified chain.


The central interval of width p is defined to be (ql,qh) where ql is the (1-p)/2 quantile and qh is the 1 - ql quantile.

Parameters
kChain index.
nParameter index.
probWidth of central interval.
Returns
Pair consisting of low and high quantile.
Exceptions
std::out_of_rangeIf the chain index is greater than or equal to the number of chains or if the parameter index is greater than the number of parameters
std::invalid_argumentIf the the interval width is not between 0 and 1 inclusive.

Definition at line 1340 of file chains.hpp.

◆ central_interval() [2/2]

template<typename RNG = boost::random::ecuyer1988>
std::pair<double,double> stan::mcmc::chains< RNG >::central_interval ( size_t  n,
double  prob 
)
inline

Return the specified central interval for the specified parameter in the kept samples of all chains.

The central interval of width p is defined to be (ql,qh) where ql is the (1 - p) / 2 quantile and qh is the 1 - ql quantile.

Parameters
nParameter index.
probWidth of central interval.
Returns
Pair consisting of low and high quantile.
Exceptions
std::out_of_rangeIf the parameter index is greater than the number of parameters
std::invalid_argumentIf the the interval width is not between 0 and 1 inclusive.

Definition at line 1369 of file chains.hpp.

◆ correlation() [1/2]

template<typename RNG = boost::random::ecuyer1988>
double stan::mcmc::chains< RNG >::correlation ( size_t  k,
size_t  n1,
size_t  n2 
)
inline

Return the correlation of the kept samples in the specified chain for the specified parameters.


Parameters
kChain index.
n1Parameter index 1.
n2Parameter index 2.
Returns
Correlation of parameters in chain.
Exceptions
std::out_of_rangeIf the chain index is greater than or equal to the number of chains or the parameter index is greater than or equal to the number of parameters.

Definition at line 1137 of file chains.hpp.

◆ correlation() [2/2]

template<typename RNG = boost::random::ecuyer1988>
double stan::mcmc::chains< RNG >::correlation ( size_t  n1,
size_t  n2 
)
inline

Return the correlation of the kept samples for the specified parameters.


Parameters
n1Parameter index 1.
n2Parameter index 2.
Returns
Correlation of kept samples for parameter.
Exceptions
std::out_of_rangeIf the parameter index is greater than or equal to the number of parameters.

Definition at line 1158 of file chains.hpp.

◆ covariance() [1/2]

template<typename RNG = boost::random::ecuyer1988>
double stan::mcmc::chains< RNG >::covariance ( size_t  k,
size_t  n1,
size_t  n2 
)
inline

Return the covariance of the kept samples in the specified chain for the specified parameters.


Parameters
kChain index.
n1Parameter index 1.
n2Parameter index 2.
Returns
Covariance of parameters in chain.
Exceptions
std::out_of_rangeIf the chain index is greater than or equal to the number of chains or the parameter index is greater than or equal to the number of parameters.

Definition at line 1068 of file chains.hpp.

◆ covariance() [2/2]

template<typename RNG = boost::random::ecuyer1988>
double stan::mcmc::chains< RNG >::covariance ( size_t  n1,
size_t  n2 
)
inline

Return the covariance of the kept samples for the specified parameters.


Parameters
n1Parameter index 1.
n2Parameter index 2.
Returns
Covariance of kept samples for parameter.
Exceptions
std::out_of_rangeIf the parameter index is greater than or equal to the number of parameters.

Definition at line 1102 of file chains.hpp.

◆ effective_sample_size()

template<typename RNG = boost::random::ecuyer1988>
double stan::mcmc::chains< RNG >::effective_sample_size ( size_t  n)
inline

Returns the effective sample size for the specified parameter across all kept samples.

The implementation matches BDA3's effective size description.

Current implementation takes the minimum number of samples across chains as the number of samples per chain.

Parameters
[in]nParameter index
Returns
the effective sample size.

Definition at line 1426 of file chains.hpp.

◆ get_kept_samples()

template<typename RNG = boost::random::ecuyer1988>
void stan::mcmc::chains< RNG >::get_kept_samples ( size_t  k,
size_t  n,
std::vector< double > &  samples 
)
inline

Write into the specified vector the kept samples for the scalar parameter with the specified index in the chain with the specified index.

The order of samples is the order in which they were added.

Synchronization: Chain-specific read.

Parameters
kIndex of chain.
nIndex of parameter.
samplesVector into which to write samples
Exceptions
std::out_of_rangeIf the specified chain index is greater than or equal to the number of chains, or if the specified parameter index is greater than or equal to the total number of parameters.

Definition at line 844 of file chains.hpp.

◆ get_kept_samples_permuted()

template<typename RNG = boost::random::ecuyer1988>
void stan::mcmc::chains< RNG >::get_kept_samples_permuted ( size_t  n,
std::vector< double > &  samples 
)
inline

Write into the specified vector the kept samples for the scalar parameter with the specified index.

The order of samples is permuted, but as long as no samples have been added in the interim, subsequent calls to this method will use the same permutation for all parameter indexes.

Synchronization: Cross-chain read.

Parameters
nIndex of parameter.
samplesVector into which samples are written.
Exceptions
std::out_of_rangeIf the parameter index is greater than or equal to the total number of scalar parameters.

Definition at line 771 of file chains.hpp.

◆ get_samples() [1/2]

template<typename RNG = boost::random::ecuyer1988>
void stan::mcmc::chains< RNG >::get_samples ( size_t  k,
size_t  n,
std::vector< double > &  samples 
)
inline

Write into the specified vector the warmup and kept samples for the scalar parameter with the specified index in the chain with the specified index.

The order of samples is the order in which they were added.

Synchronization: Chain-specific read.

Parameters
kIndex of chain.
nIndex of parameter.
samplesVector into which to write samples
Exceptions
std::out_of_rangeIf the specified chain index is greater than or equal to the number of chains, or if the specified parameter index is greater than or equal to the total number of parameters.

Definition at line 743 of file chains.hpp.

◆ get_samples() [2/2]

template<typename RNG = boost::random::ecuyer1988>
void stan::mcmc::chains< RNG >::get_samples ( size_t  n,
std::vector< double > &  samples 
)
inline

Write into the specified vector the warmup and kept samples for the scalar parameter with the specified index.

The order of samples is by chain, then by order in which the sample was added to the chain.

Synchronization: Cross-chain read.

Parameters
nIndex of parameter.
samplesVector into which samples are written.
Exceptions
std::out_of_rangeIf the parameter index is greater than or equal to the total number of scalar parameters.

Definition at line 717 of file chains.hpp.

◆ get_total_param_index()

template<typename RNG = boost::random::ecuyer1988>
size_t stan::mcmc::chains< RNG >::get_total_param_index ( size_t  j,
const std::vector< size_t > &  idxs 
)
inline

Return the index in the underlying sequence of scalar parameters for the parameter with the specified name index and indexes.

Synchronization: Thread safe.

Parameters
jIndex of parameter name.
idxsIndexes into parameter.
Returns
Offset into the underlying sequence of scalar paramters.
Exceptions
std::out_of_rangeIf the named parameter index is greater than or equal to the number of named parameters or if any of the indexes is out of range for the named parameter with the specified index.

Definition at line 552 of file chains.hpp.

◆ get_warmup_samples() [1/2]

template<typename RNG = boost::random::ecuyer1988>
void stan::mcmc::chains< RNG >::get_warmup_samples ( size_t  k,
size_t  n,
std::vector< double > &  samples 
)
inline

Write into the specified vector the warmup samples for the parameter with the specified index in the chain with the specified index.

The order of samples is the order in which they were added.

Synchronization: Chain-specific read.

Parameters
kIndex of chain.
nIndex of parameter.
samplesVector into which to write samples
Exceptions
std::out_of_rangeIf the specified chain index is greater than or equal to the number of chains, or if the specified parameter index is greater than or equal to the total number of parameters.

Definition at line 904 of file chains.hpp.

◆ get_warmup_samples() [2/2]

template<typename RNG = boost::random::ecuyer1988>
void stan::mcmc::chains< RNG >::get_warmup_samples ( size_t  n,
std::vector< double > &  samples 
)
inline

Write into the specified vector the warmup samples for the scalar parameter with the specified index.

The order of samples is by chain, then by order in which the sample was added to the chain.

Synchronization: Cross-chain read.

Parameters
nIndex of parameter.
samplesVector into which samples are written.
Exceptions
std::out_of_rangeIf the parameter index is greater than or equal to the total number of scalar parameters.

Definition at line 871 of file chains.hpp.

◆ mean() [1/2]

template<typename RNG = boost::random::ecuyer1988>
double stan::mcmc::chains< RNG >::mean ( size_t  k,
size_t  n 
)
inline

Return the sample mean of the kept samples in the specified chain for the specified parameter.

Parameters
kChain index.
nParameter index.
Returns
Sample mean of parameter in chain.
Exceptions
std::out_of_rangeIf the chain index is greater than or equal to the number of chains or the parameter index is greater than or equal to the number of parameters.

Definition at line 932 of file chains.hpp.

◆ mean() [2/2]

template<typename RNG = boost::random::ecuyer1988>
double stan::mcmc::chains< RNG >::mean ( size_t  n)
inline

Return the sample mean of the kept samples in all chains for the specified parameter.

Parameters
nParameter index.
Exceptions
std::out_of_rangeIf the parameter index is greater than or equal to the number of parameters.

Definition at line 952 of file chains.hpp.

◆ num_chains()

template<typename RNG = boost::random::ecuyer1988>
size_t stan::mcmc::chains< RNG >::num_chains ( )
inline

Return the number of chains.

Synchronization: Thread safe.

Returns
The number of chains.

Definition at line 371 of file chains.hpp.

◆ num_kept_samples() [1/2]

template<typename RNG = boost::random::ecuyer1988>
size_t stan::mcmc::chains< RNG >::num_kept_samples ( )
inline

Return the total number of samples in all chains not including warmup samples.

Synchronization: Warmup and cross-chain read.

Returns
Total number of warmup samples

Definition at line 664 of file chains.hpp.

◆ num_kept_samples() [2/2]

template<typename RNG = boost::random::ecuyer1988>
size_t stan::mcmc::chains< RNG >::num_kept_samples ( size_t  k)
inline

Return the number of samples in the specified chain not including warmup samples.

Synchronization: Warmup and chain-specific read.

Parameters
kChain index.
Returns
Number of warmup samples availabe in chain.

Definition at line 649 of file chains.hpp.

◆ num_param_names()

template<typename RNG = boost::random::ecuyer1988>
size_t stan::mcmc::chains< RNG >::num_param_names ( )
inline

Return the total number of parameter names.

Synchronization: Thread safe.

Returns
The total number of parameter names.

Definition at line 396 of file chains.hpp.

◆ num_params()

template<typename RNG = boost::random::ecuyer1988>
size_t stan::mcmc::chains< RNG >::num_params ( )
inline

Return the total number of parameters.


This is not the number of parameter names, but the total number of scalar parameters.

Synchronization: Thread safe.

Returns
The total number of parameters.

Definition at line 385 of file chains.hpp.

◆ num_samples() [1/2]

template<typename RNG = boost::random::ecuyer1988>
size_t stan::mcmc::chains< RNG >::num_samples ( )
inline

Return the total number of samples across chains including warmup and kept samples.

Synchronization: Cross-chain read.

Returns
Total number of samples.

Definition at line 679 of file chains.hpp.

◆ num_samples() [2/2]

template<typename RNG = boost::random::ecuyer1988>
size_t stan::mcmc::chains< RNG >::num_samples ( size_t  k)
inline

Return the number of samples including warmup and kept samples in the specified chain.

Synchronization: Chain-specific read.

Parameters
kMarkov chain index.
Returns
Number of samples in the specified chain.
Exceptions
std::out_of_rangeIf the identifier is greater than or equal to the number of chains.

Definition at line 697 of file chains.hpp.

◆ num_warmup_samples() [1/2]

template<typename RNG = boost::random::ecuyer1988>
size_t stan::mcmc::chains< RNG >::num_warmup_samples ( )
inline

Return the total number of warmup samples across chains.

Synchronization: Warmup and cross-chain read.

Returns
The total number of warmup samples.

Definition at line 633 of file chains.hpp.

◆ num_warmup_samples() [2/2]

template<typename RNG = boost::random::ecuyer1988>
size_t stan::mcmc::chains< RNG >::num_warmup_samples ( size_t  k)
inline

Return the number of warmup samples in the specified chain.

Synchronization: Warmup and chain-specific read.

Parameters
kChain index.
Returns
Number of warmup samples availabe in chain.

Definition at line 622 of file chains.hpp.

◆ param_dims()

template<typename RNG = boost::random::ecuyer1988>
const std::vector<size_t>& stan::mcmc::chains< RNG >::param_dims ( size_t  j)
inline

Return the dimensions of the parameter name with the specified index.

Synchronization: Thread safe.

Parameters
jIndex of a parameter name.
Returns
The dimensions of the parameter name with the specified index.
Exceptions
std::out_of_rangeIf the index is greater than or equal to the number of parameter names.

Definition at line 449 of file chains.hpp.

◆ param_dimss()

template<typename RNG = boost::random::ecuyer1988>
const std::vector<std::vector<size_t> >& stan::mcmc::chains< RNG >::param_dimss ( )
inline

Return the sequence of named parameter dimensions.


Synchronization: Thread safe after construction.

Returns
The sequence of named parameter dimensions.

Definition at line 433 of file chains.hpp.

◆ param_name()

template<typename RNG = boost::random::ecuyer1988>
const std::string& stan::mcmc::chains< RNG >::param_name ( size_t  j)
inline

Return the name of the parameter with the specified index.

Synchronization: Thread safe.

Parameters
jIndex of parameter.
Returns
The parameter with the specified index.
Exceptions
std::out_of_rangeIf the parameter identifier is greater than or equal to the number of parameters.

Definition at line 421 of file chains.hpp.

◆ param_name_to_index()

template<typename RNG = boost::random::ecuyer1988>
size_t stan::mcmc::chains< RNG >::param_name_to_index ( const std::string &  name)
inline

Return the named parameter index for the specified parameter name.

Synchronization: Thread safe.

Parameters
nameParameter name.
Returns
Index of parameter name.
Exceptions
std::out_of_rangeIf the parameter is not one of the named parameters.

Definition at line 526 of file chains.hpp.

◆ param_names()

template<typename RNG = boost::random::ecuyer1988>
const std::vector<std::string>& stan::mcmc::chains< RNG >::param_names ( )
inline

Return the sequence of parameter names.

Synchronization: Thread safe after construction.

Returns
The sequence of parameter names.

Definition at line 407 of file chains.hpp.

◆ param_size()

template<typename RNG = boost::random::ecuyer1988>
size_t stan::mcmc::chains< RNG >::param_size ( size_t  j)
inline

Return the size of the named parameter with the specified index.

The size of a named parameter is the prouct of its dimensions.

Synchronization: Thread safe after construction.

Parameters
jThe index of a named parameter.
Returns
The size of the specified named parameter.
Exceptions
std::out_of_rangeIf the index is greater than or equal to the number of named parameters.

Definition at line 508 of file chains.hpp.

◆ param_sizes()

template<typename RNG = boost::random::ecuyer1988>
const std::vector<size_t> stan::mcmc::chains< RNG >::param_sizes ( )
inline

Return a copy of the sequence of named parameter sizes.

The size of a named parameter is the prouct of its dimensions.

Synchronization: Thread safe.

Returns
The sequence of named parameter sizes.

Definition at line 490 of file chains.hpp.

◆ param_start()

template<typename RNG = boost::random::ecuyer1988>
size_t stan::mcmc::chains< RNG >::param_start ( size_t  j)
inline

Return the starting position of the named parameter with the specified index in the underlying sequence of scalar parameters.

Synchronization: Thread safe.

Parameters
jThe parameter name index.
Returns
The start index of the specified parameter.
Exceptions
std::out_of_rangeIf the parameter name index is greater than or equal to the number of named parameters.

Definition at line 477 of file chains.hpp.

◆ param_starts()

template<typename RNG = boost::random::ecuyer1988>
const std::vector<size_t>& stan::mcmc::chains< RNG >::param_starts ( )
inline

Return the sequence of starting indexes for the named parameters in the underlying sequence of scalar parameters.

Synchronization: Thread safe.

Returns
The sequence of named parameter start indexes.

Definition at line 462 of file chains.hpp.

◆ quantile() [1/2]

template<typename RNG = boost::random::ecuyer1988>
double stan::mcmc::chains< RNG >::quantile ( size_t  k,
size_t  n,
double  prob 
)
inline

Return the specified sample quantile for kept samples for the specified parameter in the specified chain.

Parameters
kChain index
nParameter index
probQuantile probability
Exceptions
std::out_of_rangeIf the chain index is greater than or equal to the number of chains or if the parameter index is greater than the number of parameters
std::invalid_argumentIf the probabilty is not between 0 and 1 inclusive.

Definition at line 1180 of file chains.hpp.

◆ quantile() [2/2]

template<typename RNG = boost::random::ecuyer1988>
double stan::mcmc::chains< RNG >::quantile ( size_t  n,
double  prob 
)
inline

Return the specified sample quantile for kept samples for the specified parameter across all chains.

Parameters
nParameter index
probQuantile probability
Exceptions
std::out_of_rangeIf the parameter index is greater than the number of parameters
std::invalid_argumentIf the probabilty is not between 0 and 1 inclusive.

Definition at line 1219 of file chains.hpp.

◆ quantiles() [1/2]

template<typename RNG = boost::random::ecuyer1988>
void stan::mcmc::chains< RNG >::quantiles ( size_t  k,
size_t  n,
const std::vector< double > &  probs,
std::vector< double > &  quantiles 
)
inline

Write the specified sample quantiles into the specified vector for the kept samples for the specified parameter in the specified chain.

Parameters
kChain index
nParameter index
probsQuantile probabilities
quantilesVector into which to write sample quantiles
Exceptions
std::out_of_rangeIf the chain index is greater than or equal to the number of chains or if the parameter index is greater than the number of parameters
std::invalid_argumentIf the any quantile probabilty is not between 0 and 1 inclusive.

Definition at line 1260 of file chains.hpp.

◆ quantiles() [2/2]

template<typename RNG = boost::random::ecuyer1988>
void stan::mcmc::chains< RNG >::quantiles ( size_t  n,
const std::vector< double > &  probs,
std::vector< double > &  quantiles 
)
inline

Write the specified sample quantiles into the specified vector for the kept samples for the specified parameter across all chains.

Parameters
nParameter index
probsQuantile probabilities
quantilesVector into which to write sample quantiles
Exceptions
std::out_of_rangeIf the parameter index is greater than the number of parameters
std::invalid_argumentIf the any quantile probabilty is not between 0 and 1 inclusive.

Definition at line 1299 of file chains.hpp.

◆ sd() [1/2]

template<typename RNG = boost::random::ecuyer1988>
double stan::mcmc::chains< RNG >::sd ( size_t  k,
size_t  n 
)
inline

Return the sample standard deviation of the kept samples in the specified chain for the specified parameter.

This method uses the unbiased variance estimator (and thus divides by M-1 rather than M in the denominator)

Parameters
kChain index.
nParameter index.
Returns
Sample mean of parameter in chain.
Exceptions
std::out_of_rangeIf the chain index is greater than or equal to the number of chains or the parameter index is greater than or equal to the number of parameters.

Definition at line 975 of file chains.hpp.

◆ sd() [2/2]

template<typename RNG = boost::random::ecuyer1988>
double stan::mcmc::chains< RNG >::sd ( size_t  n)
inline

Return the sample standard deviation of the kept samples in all chains for the specified parameter.

This method divides by the number of kept samples minus 1 (and is htus based on an unbiased variance estimate from the samples).

Parameters
nParameter index.
Returns
Sample standard deviation of kept samples for parameter.
Exceptions
std::out_of_rangeIf the parameter index is greater than or equal to the number of parameters.

Definition at line 1000 of file chains.hpp.

◆ set_warmup()

template<typename RNG = boost::random::ecuyer1988>
void stan::mcmc::chains< RNG >::set_warmup ( size_t  warmup_iterations)
inline

Set the warmup cutoff to the specified number of iterations.

The first samples in each chain up to this number will be treated as warmup samples.

Synchronization: Warmup write method.

Parameters
warmup_iterationsNumber of warmup iterations.

Definition at line 568 of file chains.hpp.

◆ split_potential_scale_reduction()

template<typename RNG = boost::random::ecuyer1988>
double stan::mcmc::chains< RNG >::split_potential_scale_reduction ( size_t  n)
inline

Return the split potential scale reduction (split R hat) for the specified parameter.

Current implementation takes the minimum number of samples across chains as the number of samples per chain.

Parameters
[in]nParameter index
Returns
split R hat.

Definition at line 1483 of file chains.hpp.

◆ variance() [1/2]

template<typename RNG = boost::random::ecuyer1988>
double stan::mcmc::chains< RNG >::variance ( size_t  k,
size_t  n 
)
inline

Return the variance of the kept samples in the specified chain for the specified parameter.


Parameters
kChain index.
nParameter index.
Returns
Variance of parameter in chain.
Exceptions
std::out_of_rangeIf the chain index is greater than or equal to the number of chains or the parameter index is greater than or equal to the number of parameters.

Definition at line 1022 of file chains.hpp.

◆ variance() [2/2]

template<typename RNG = boost::random::ecuyer1988>
double stan::mcmc::chains< RNG >::variance ( size_t  n)
inline

Return the variance of the kept samples in all chains for the specified parameter.


Parameters
nParameter index.
Returns
Variance of kept samples for parameter.
Exceptions
std::out_of_rangeIf the parameter index is greater than or equal to the number of parameters.

Definition at line 1045 of file chains.hpp.

◆ warmup()

template<typename RNG = boost::random::ecuyer1988>
size_t stan::mcmc::chains< RNG >::warmup ( )
inline

Return the warmup iteration cutoff.

Synchronization: Warmup read method.

Returns
Number of warmup iterations.

Definition at line 580 of file chains.hpp.


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

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