1function [xparams, logpost] = GetOneDraw(type,M_,estim_params_,oo_,options_,bayestopt_)
2% function [xparams, logpost] = GetOneDraw(type,M_,estim_params_,oo_,options_,bayestopt_)
3% draws one parameter vector and its posterior from MCMC or the prior
4%
5% INPUTS
6%    type:      [string]       'posterior': draw from MCMC draws
7%                              'prior': draw from prior
8%    M_         [structure]     Definition of the model
9%    estim_params_ [structure]  characterizing parameters to be estimated
10%    oo_         [structure]    Storage of results
11%    options_    [structure]    Options
12%    bayestopt_  [structure]    describing the priors
13%
14% OUTPUTS
15%    xparams:   vector of estimated parameters (drawn from posterior or prior distribution)
16%    logpost:   log of the posterior density of this parameter vector
17%
18% SPECIAL REQUIREMENTS
19%    none
20
21% Copyright (C) 2005-2017 Dynare Team
22%
23% This file is part of Dynare.
24%
25% Dynare is free software: you can redistribute it and/or modify
26% it under the terms of the GNU General Public License as published by
27% the Free Software Foundation, either version 3 of the License, or
28% (at your option) any later version.
29%
30% Dynare is distributed in the hope that it will be useful,
31% but WITHOUT ANY WARRANTY; without even the implied warranty of
32% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
33% GNU General Public License for more details.
34%
35% You should have received a copy of the GNU General Public License
36% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
37
38switch type
39  case 'posterior'
40    [xparams, logpost] = metropolis_draw(0);
41  case 'prior'
42    xparams = prior_draw();
43    if nargout>1
44        logpost = evaluate_posterior_kernel(xparams',M_,estim_params_,oo_,options_,bayestopt_);
45    end
46end