diff --git a/matlab/+identification/run.m b/matlab/+identification/run.m index 38bfe21eed924a7368ae228a2ec0d09574ca0598..e3c1a24b205564008135c22a53b580f293979522 100644 --- a/matlab/+identification/run.m +++ b/matlab/+identification/run.m @@ -45,14 +45,14 @@ function [pdraws, STO_REDUCEDFORM, STO_MOMENTS, STO_DYNAMIC, STO_si_dDYNAMIC, ST % * identification.analysis % * isoctave % * identification.plot -% * dprior.draw +% * dprior.deviate % * set_default_option % * set_prior % * skipline % * vnorm % ========================================================================= -% Copyright © 2010-2023 Dynare Team +% Copyright © 2010-2024 Dynare Team % % This file is part of Dynare. % @@ -485,7 +485,7 @@ if iload <=0 kk=0; while kk<50 && info(1) kk=kk+1; - params = Prior.draw(); + params = Prior.deviate(); options_ident.tittxt = 'Random_prior_params'; %title text for graphs and figures % perform identification analysis [ide_moments_point, ide_spectrum_point, ide_minimal_point, ide_hess_point, ide_reducedform_point, ide_dynamic_point, ~, info, error_indicator_point] = ... @@ -540,7 +540,7 @@ if iload <=0 if external_sample params = pdraws0(iteration+1,:); % loaded draws else - params = Prior.draw(); % new random draw from prior + params = Prior.deviate(); % new random draw from prior end options_ident.tittxt = []; % clear title text for graphs and figures % run identification analysis diff --git a/matlab/@dprior/admissible.m b/matlab/@dprior/admissible.m index 82cce25f3ef61198f7d6dee7ecd6acd9d44d991f..0bc685dae68f734b0c724dddb35b863754b380b2 100644 --- a/matlab/@dprior/admissible.m +++ b/matlab/@dprior/admissible.m @@ -15,7 +15,7 @@ function b = admissible(o, d) % EXAMPLE % % >> Prior = dprior(bayestopt_, options_.prior_trunc); -% >> d = Prior.draw() +% >> d = Prior.deviate() % >> Prior.admissible(d) % ans = % @@ -23,7 +23,7 @@ function b = admissible(o, d) % % 1 -% Copyright © 2023 Dynare Team +% Copyright © 2023-2024 Dynare Team % % This file is part of Dynare. % @@ -131,7 +131,7 @@ try o = dprior(BayesInfo, prior_trunc, false); % Do simulations in a loop and estimate recursively the mean and the variance. for i = 1:ndraws - draw = o.draw(); + draw = o.deviate(); if ~o.admissible(draw) error('problem in admissible') end diff --git a/matlab/@dprior/density.m b/matlab/@dprior/density.m index 740d0b408dba677e7bc857e3eb46389371208488..805446679c7f97ee905922695f115c9d193e0996 100644 --- a/matlab/@dprior/density.m +++ b/matlab/@dprior/density.m @@ -20,7 +20,7 @@ function [lpd, dlpd, d2lpd, info] = density(o, x) % >> Prior = dprior(bayestopt_, options_.prior_trunc); % >> lpd = Prior.dsensity(x) -% Copyright © 2023 Dynare Team +% Copyright © 2023-2024 Dynare Team % % This file is part of Dynare. % @@ -269,7 +269,7 @@ try % Draw random deviates in a loop and evaluate the density. LPD = NaN(10000,1); parfor i = 1:10000 - x = Prior.draw(); + x = Prior.deviate(); LPD(i) = Prior.density(x); end t(1) = true; diff --git a/matlab/@dprior/draw.m b/matlab/@dprior/deviate.m similarity index 96% rename from matlab/@dprior/draw.m rename to matlab/@dprior/deviate.m index bad82885a75de127670facd255ee225c5447dd3b..6a916c890de014711f25daa3ff6b7c2753623132 100644 --- a/matlab/@dprior/draw.m +++ b/matlab/@dprior/deviate.m @@ -1,4 +1,4 @@ -function p = draw(o) +function p = deviate(o) % Return a random draw from the prior distribution. % @@ -14,9 +14,9 @@ function p = draw(o) % EXAMPLE % % >> Prior = dprior(bayestopt_, options_.prior_trunc); -% >> d = Prior.draw() +% >> d = Prior.deviate() -% Copyright © 2023 Dynare Team +% Copyright © 2023-2024 Dynare Team % % This file is part of Dynare. % @@ -178,11 +178,11 @@ try o = dprior(BayesInfo, prior_trunc, false); % Do simulations in a loop and estimate recursively the mean and the variance. for i = 1:ndraws - draw = o.draw(); - m1 = m0 + (draw-m0)/i; - m2 = m1*m1'; - v0 = v0 + ((draw*draw'-m2-v0) + (i-1)*(m0*m0'-m2'))/i; - m0 = m1; + draw = o.deviate(); + m1 = m0 + (draw-m0)/i; + m2 = m1*m1'; + v0 = v0 + ((draw*draw'-m2-v0) + (i-1)*(m0*m0'-m2'))/i; + m0 = m1; end t(1) = true; catch diff --git a/matlab/@dprior/draws.m b/matlab/@dprior/sample.m similarity index 96% rename from matlab/@dprior/draws.m rename to matlab/@dprior/sample.m index 88b92abd4ac37d191711f64cfd1b67cf65494fa8..26505b4b6a74becdda1e46ff74fbb49f5d346dab 100644 --- a/matlab/@dprior/draws.m +++ b/matlab/@dprior/sample.m @@ -1,4 +1,4 @@ -function P = draws(o, n) +function P = sample(o, n) % Return n independent random draws from the prior distribution. % @@ -14,9 +14,9 @@ function P = draws(o, n) % EXAMPLE % % >> Prior = dprior(bayestopt_, options_.prior_trunc); -% >> Prior.draws(1e6) +% >> Prior.sample(1e6) -% Copyright © 2023 Dynare Team +% Copyright © 2023-2024 Dynare Team % % This file is part of Dynare. % @@ -35,7 +35,7 @@ function P = draws(o, n) P = NaN(rows(o.lb), 1); parfor i=1:n - P(:,i) = draw(o); + P(:,i) = deviate(o); end return % --*-- Unit tests --*-- @@ -117,7 +117,7 @@ ndraws = 1e5; try % Instantiate dprior object. o = dprior(BayesInfo, prior_trunc, false); - X = o.draws(ndraws); + X = o.sample(ndraws); m = mean(X, 2); v = var(X, 0, 2); t(1) = true; diff --git a/matlab/@dprior/subsref.m b/matlab/@dprior/subsref.m index 692f813d0055dafeeebe58a5e6ac0a67e86f3594..b4f2915ed86150c6c8cdee0199d478a41c21b744 100644 --- a/matlab/@dprior/subsref.m +++ b/matlab/@dprior/subsref.m @@ -2,7 +2,7 @@ function p = subsref(o, S) % Overload subsref method. -% Copyright © 2023 Dynare Team +% Copyright © 2023-2024 Dynare Team % % This file is part of Dynare. % @@ -25,9 +25,9 @@ switch S(1).type p = builtin('subsref', o, S(1)); elseif isequal(S(1).subs, 'bounds') && length(S)==1 p = bounds(o, [], false); - elseif ismember(S(1).subs, {'draw','length'}) + elseif ismember(S(1).subs, {'deviate','length','isempty'}) p = feval(S(1).subs, o); - elseif ismember(S(1).subs, {'draws', 'density', 'densities', 'moments', 'admissible', 'bounds'}) + elseif ismember(S(1).subs, {'sample', 'density', 'densities', 'moments', 'admissible', 'bounds'}) p = feval(S(1).subs, o , S(2).subs{:}); elseif ismember(S(1).subs, {'mean', 'median', 'variance', 'mode'}) if (length(S)==2 && isempty(S(2).subs)) || length(S)==1 diff --git a/matlab/dseries b/matlab/dseries index 5436f91fe709b7e9f31302714cc1f9a7271001c6..a456425a6ff65c699f5937c0ea775de1a3348405 160000 --- a/matlab/dseries +++ b/matlab/dseries @@ -1 +1 @@ -Subproject commit 5436f91fe709b7e9f31302714cc1f9a7271001c6 +Subproject commit a456425a6ff65c699f5937c0ea775de1a3348405 diff --git a/matlab/estimation/PosteriorIRF_core1.m b/matlab/estimation/PosteriorIRF_core1.m index fa29c9f4b23730e978ce6e2ab47334b863016c96..68086622ccac3e1bfd5a55e44d2093bea5f59b37 100644 --- a/matlab/estimation/PosteriorIRF_core1.m +++ b/matlab/estimation/PosteriorIRF_core1.m @@ -23,8 +23,8 @@ function myoutput=PosteriorIRF_core1(myinputs,fpar,B,whoiam, ThisMatlab) % % SPECIAL REQUIREMENTS. % None. -% -% Copyright © 2006-2023 Dynare Team + +% Copyright © 2006-2024 Dynare Team % % This file is part of Dynare. % @@ -135,7 +135,7 @@ while fpar<B irun = irun+1; irun2 = irun2+1; if strcmpi(type,'prior') - deep = Prior.draw(); + deep = Prior.deviate(); else deep = x(fpar,:); end diff --git a/matlab/estimation/execute_prior_posterior_function.m b/matlab/estimation/execute_prior_posterior_function.m index 5bd2e98ed578d8603ac4ca5af93c13c8eabe784e..0429f8e57dc38be88fa91fad179b16eeaea2219b 100644 --- a/matlab/estimation/execute_prior_posterior_function.m +++ b/matlab/estimation/execute_prior_posterior_function.m @@ -78,7 +78,7 @@ end if strcmpi(type, 'prior') - parameter_mat = Prior.draws(n_draws); + parameter_mat = Prior.sample(n_draws); else parameter_mat=get_posterior_subsample(M_,options_,n_draws)'; end diff --git a/matlab/estimation/online/online_auxiliary_filter.m b/matlab/estimation/online/online_auxiliary_filter.m index ebe1394ff1d2e18c98bfd4e4e69aa3f5f848e7f9..3ad452080884e86d6c2f2d0d92f6f85fd2eee315 100644 --- a/matlab/estimation/online/online_auxiliary_filter.m +++ b/matlab/estimation/online/online_auxiliary_filter.m @@ -11,7 +11,7 @@ function online_auxiliary_filter(xparam1, dataset_, options_, M_, estim_params_, % - estim_params_ [struct] Description of the estimated parameters. % - bayestopt_ [struct] Prior definition. % - oo_ [struct] Results. -% + % Copyright © 2013-2024 Dynare Team % % This file is part of Dynare. @@ -79,7 +79,7 @@ Prior = dprior(bayestopt_, options_.prior_trunc); for i=1:number_of_particles info = 12042009; while info - candidate = Prior.draw(); + candidate = Prior.deviate(); [info, M_, options_, oo_] = solve_model_for_online_filter(false, candidate, dataset_, options_, M_, estim_params_, bayestopt_, bounds, oo_); if ~info xparam(:,i) = candidate(:); diff --git a/matlab/estimation/posterior_sampler_initialization.m b/matlab/estimation/posterior_sampler_initialization.m index 194f4c3c30f1401043e3157d734ecae1a143fd33..354b00916f27e80c8e35af2739241650bd687112 100644 --- a/matlab/estimation/posterior_sampler_initialization.m +++ b/matlab/estimation/posterior_sampler_initialization.m @@ -194,7 +194,7 @@ if ~options_.load_mh_file && ~options_.mh_recover trial = 1; while ~validate && trial <= 10 if isempty(d) - candidate = Prior.draw(); + candidate = Prior.deviate(); else if isfield(options_,'mh_init_scale') if trial==1 diff --git a/matlab/estimation/prior_posterior_statistics_core.m b/matlab/estimation/prior_posterior_statistics_core.m index 478dab2e60eda6405d0995d83c786f226f79e138..10add4c6305c5ce0a3c261c947284ad167339f4b 100644 --- a/matlab/estimation/prior_posterior_statistics_core.m +++ b/matlab/estimation/prior_posterior_statistics_core.m @@ -30,7 +30,7 @@ function myoutput=prior_posterior_statistics_core(myinputs,fpar,B,whoiam, ThisMa % SPECIAL REQUIREMENTS. % None. -% Copyright © 2005-2023 Dynare Team +% Copyright © 2005-2024 Dynare Team % % This file is part of Dynare. % @@ -198,7 +198,7 @@ for b=fpar:B iter=1; logpo=[]; while (isempty(logpo) || isinf(logpo)) && iter<1000 - deep = Prior.draw(); + deep = Prior.deviate(); logpo = evaluate_posterior_kernel(deep, M_, estim_params_, oo_, options_, bayestopt_); iter=iter+1; end diff --git a/matlab/estimation/prior_sampler.m b/matlab/estimation/prior_sampler.m index 3521df61f3befa36cd0d34382244e1a562a10198..eef835b1f74cd6ac4262b0db3afb14f38ed7d74b 100644 --- a/matlab/estimation/prior_sampler.m +++ b/matlab/estimation/prior_sampler.m @@ -93,7 +93,7 @@ while iteration < NumberOfSimulations dyn_waitbar(iteration/NumberOfSimulations,hh_fig,'Please wait. Prior sampler...'); end loop_indx = loop_indx+1; - params = Prior.draw(); + params = Prior.deviate(); M_ = set_all_parameters(params, estim_params_, M_); [T, R, ~, INFO, oo_.dr,M_.params] = dynare_resolve(M_, options_, oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state, 'restrict'); if ~INFO(1) diff --git a/matlab/estimation/slice_sampler.m b/matlab/estimation/slice_sampler.m index 326df5ff0d227c687df005c0876a6186a528e540..fcf4a818be49efffc194c1d0046db2cc1f68979e 100644 --- a/matlab/estimation/slice_sampler.m +++ b/matlab/estimation/slice_sampler.m @@ -24,7 +24,7 @@ function [theta, fxsim, neval] = slice_sampler(objective_function,theta,thetapri % SPECIAL REQUIREMENTS % none -% Copyright © 2015-2023 Dynare Team +% Copyright © 2015-2024 Dynare Team % % This file is part of Dynare. % @@ -82,7 +82,7 @@ while it<npar icount=0; while ~isfinite(fxold) && icount<1000 icount=icount+1; - theta = Prior.draw(); + theta = Prior.deviate(); if all(theta >= thetaprior(:,1)) && all(theta <= thetaprior(:,2)) fxold = -feval(objective_function,theta,varargin{:}); end diff --git a/matlab/estimation/smc/smc_samplers_initialization.m b/matlab/estimation/smc/smc_samplers_initialization.m index 4c17ef0ade4aa9f0f99b70aff01501b5666fb870..64041a73a4556244d46381786e5fb12fc2bc6a08 100644 --- a/matlab/estimation/smc/smc_samplers_initialization.m +++ b/matlab/estimation/smc/smc_samplers_initialization.m @@ -56,7 +56,7 @@ t0 = tic; parfor j=1:n notvalid = true; while notvalid - candidate = Prior.draw(); + candidate = Prior.deviate(); if Prior.admissible(candidate) particles(:,j) = candidate; [tlogpostkernel(j), loglikelihood(j)] = tempered_likelihood(funobj, candidate, 0.0, Prior); diff --git a/preprocessor b/preprocessor index 86822b5e6e8b5fc3f98673d6e6d21eed8051e2d4..a091c26ced0fba215851485e824502230fccb73f 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 86822b5e6e8b5fc3f98673d6e6d21eed8051e2d4 +Subproject commit a091c26ced0fba215851485e824502230fccb73f