예제 #1
0
      /**
       * Outputs parameter string names. First outputs the names stored in
       * the sample object (stan::mcmc::sample), then uses the sampler provided
       * to output sampler specific names, then adds the model constrained
       * parameter names.
       *
       * The names are written to the sample_stream as comma separated values
       * with a newline at the end.
       *
       * @param sample a sample (unconstrained) that works with the model
       * @param sampler a stan::mcmc::base_mcmc object
       * @param model the model
       *
       * @pre none
       * @post none
       * @sideeffects sample_stream_ is written to with comma separated values
       *   with a newline at the end
       */
      void write_sample_names(stan::mcmc::sample& sample,
                              stan::mcmc::base_mcmc* sampler,
                              M& model) {
        std::vector<std::string> names;

        sample.get_sample_param_names(names);
        sampler->get_sampler_param_names(names);
        model.constrained_param_names(names, true, true);

        sample_writer_(names);
      }
예제 #2
0
      /**
       * Print diagnostic names
       *
       * @param sample unconstrained sample
       * @param sampler sampler
       * @param model model
       *
       * @pre sample, sampler, and model are consistent.
       * @post none
       * @sideeffects diagnostic_stream_ is appended with comma
       *   separated names with newline at the end
       */
      void write_diagnostic_names(stan::mcmc::sample sample,
                                  stan::mcmc::base_mcmc* sampler,
                                  M& model) {
        std::vector<std::string> names;

        sample.get_sample_param_names(names);
        sampler->get_sampler_param_names(names);

        std::vector<std::string> model_names;
        model.unconstrained_param_names(model_names, false, false);

        sampler->get_sampler_diagnostic_names(model_names, names);

        diagnostic_writer_(names);
      }
예제 #3
0
 /*
  * @param iter_param_names
  * @param sampler_param_names
  */
 void set_output_names(stan::mcmc::sample& s, 
                       stan::mcmc::base_mcmc* sampler_ptr,
                       M& model,
                       std::vector<std::string>& iter_param_names,
                       std::vector<std::string>& sampler_param_names) { 
   sample_names_.clear();
   s.get_sample_param_names(sample_names_);
   index_for_lp_ = find_index(sample_names_, std::string("lp__")); 
   sampler_names_.clear();
   sampler_ptr -> get_sampler_param_names(sampler_names_);
   param_names_.clear();
   model.constrained_param_names(param_names_, true, true);
   iter_param_names = sample_names_;
   sampler_param_names = sampler_names_;
 }
예제 #4
0
    void output_diagnostic_names(stan::mcmc::sample& s,
                                 stan::mcmc::base_mcmc* sampler_ptr, 
                                 M& model) {
      if (!pdiagnostic_stream_) return;

      std::vector<std::string> names;
      s.get_sample_param_names(names);
      sampler_ptr -> get_sampler_param_names(names);
      std::vector<std::string> model_names;
      model.unconstrained_param_names(model_names, false, false);
      sampler_ptr -> get_sampler_diagnostic_names(model_names, names);
        
      (*pdiagnostic_stream_) << names.at(0);
      for (size_t i = 1; i < names.size(); ++i) {
        (*pdiagnostic_stream_) << "," << names.at(i);
      }
      (*pdiagnostic_stream_) << std::endl;
    }
예제 #5
0
 void print_sample_names(stan::mcmc::sample& sample,
                         stan::mcmc::base_mcmc* sampler,
                         M& model) {
   
   if(!_sample_stream) return;
   
   std::vector<std::string> names;
   
   sample.get_sample_param_names(names);
   sampler->get_sampler_param_names(names);
   model.constrained_param_names(names, true, true);
  
   (*_sample_stream) << names.at(0);
   for (size_t i = 1; i < names.size(); ++i) {
     (*_sample_stream) << "," << names.at(i);
   }
   (*_sample_stream) << std::endl;
   
 }