Avoid using disp(sprintf()) constructs.

covariance-quadratic-approximation
Stéphane Adjemian (Guts) 2023-12-15 18:29:32 +01:00
parent 0249ea2116
commit 23af7f64b6
Signed by: stepan
GPG Key ID: 295C1FE89E17EB3C
12 changed files with 30 additions and 31 deletions

View File

@ -41,7 +41,7 @@ if options_.dsge_var && options_.bayesian_irf
for i=1:size(varlist,1)
idx = strmatch(varlist{i}, options_.varobs, 'exact');
if isempty(idx)
disp(sprintf('%s is not an observed variable!', varlist{i}))
dprintf('%s is not an observed variable!', varlist{i})
msg = true;
end
end
@ -169,4 +169,4 @@ while ~isempty(remain)
end
if index<max_number_of_words_per_line
disp(line_of_text)
end
end

View File

@ -94,7 +94,7 @@ try
for i=1:n_shapes
for j=1:n_scales
if debug
disp(sprintf('... mu=%s and s2=%s', num2str(mu(j,i)),num2str(s2(j,i))))
dprintf('... mu=%s and s2=%s', num2str(mu(j,i)),num2str(s2(j,i)))
end
if ~isnan(mu(j,i)) && ~isnan(s2(j,i)) && ~isinf(mu(j,i)) && ~isinf(s2(j,i))
[shape, scale] = weibull_specification(mu(j,i), s2(j,i));

View File

@ -54,7 +54,7 @@ if ismember(method, [1, 2])
flag = ~flag;
end
if debug
disp(sprintf('%s\t %1.8f\t %s',int2str(iteration),weight,int2str(flag)))
dprintf('%u\t %1.8f\t %u', iteration, weight, flag)
end
state(2:end) = state(1:end-1);
state(1) = flag;
@ -121,7 +121,7 @@ if isequal(method, 3) || (isequal(method, 2) && noconvergence)
flag = ~flag;
end
if debug
disp(sprintf('%s\t %1.8f\t %s',int2str(index),weight,int2str(flag)))
dprintf('%u\t %1.8f\t %u', index, weight, flag)
end
if flag
jndex = index;

View File

@ -119,11 +119,11 @@ if np
oo_ = Filloo(oo_, name, type, post_mean, hpd_interval, post_median, post_var, post_deciles, density);
end
end
disp(sprintf(pformat, header_width, name, bayestopt_.p1(ip),...
post_mean, ...
hpd_interval, ...
pnames{bayestopt_.pshape(ip)+1}, ...
bayestopt_.p2(ip)));
dprintf(pformat, header_width, name, bayestopt_.p1(ip),...
post_mean, ...
hpd_interval, ...
pnames{bayestopt_.pshape(ip)+1}, ...
bayestopt_.p2(ip));
if TeX
k = estim_params_.param_vals(i,1);
name = M_.param_names_tex{k};
@ -167,7 +167,7 @@ if nvx
M_.Sigma_e(k,k) = post_mean*post_mean;
end
end
disp(sprintf(pformat,header_width,name, bayestopt_.p1(ip), post_mean, hpd_interval, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip)));
dprintf(pformat, header_width, name, bayestopt_.p1(ip), post_mean, hpd_interval, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip));
if TeX
name = M_.exo_names_tex{k};
TeXCore(fid,name, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p1(ip), bayestopt_.p2(ip), post_mean, sqrt(post_var), hpd_interval);
@ -205,7 +205,7 @@ if nvn
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density);
end
end
disp(sprintf(pformat, header_width, name,bayestopt_.p1(ip), post_mean, hpd_interval, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip)));
dprintf(pformat, header_width, name,bayestopt_.p1(ip), post_mean, hpd_interval, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip));
if TeX
k = estim_params_.var_endo(i,1);
name = M_.endo_names_tex{k};
@ -257,7 +257,7 @@ if ncx
M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
end
end
disp(sprintf(pformat, header_width,name, bayestopt_.p1(ip), post_mean, hpd_interval, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip)));
dprintf(pformat, header_width,name, bayestopt_.p1(ip), post_mean, hpd_interval, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip));
if TeX
name = sprintf('(%s,%s)', M_.exo_names_tex{k1}, M_.exo_names_tex{k2});
TeXCore(fid, name, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p1(ip), bayestopt_.p2(ip), post_mean, sqrt(post_var), hpd_interval);
@ -304,7 +304,7 @@ if ncn
oo_ = Filloo(oo_, NAME, type, post_mean, hpd_interval, post_median, post_var, post_deciles, density);
end
end
disp(sprintf(pformat, header_width, name, bayestopt_.p1(ip), post_mean, hpd_interval, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip)));
dprintf(pformat, header_width, name, bayestopt_.p1(ip), post_mean, hpd_interval, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip));
if TeX
name = sprintf('(%s,%s)', M_.endo_names_tex{k1}, M_.endo_names_tex{k2});
TeXCore(fid, name, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p1(ip), bayestopt_.p2(ip), post_mean, sqrt(post_var), hpd_interval);

View File

@ -373,7 +373,7 @@ if ~issmc(options_) && any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode
oo_.MarginalDensity.LaplaceApproximation = NaN;
end
skipline()
disp(sprintf('Log data density [Laplace approximation] is %f.',oo_.MarginalDensity.LaplaceApproximation))
dprintf('Log data density [Laplace approximation] is %f.', oo_.MarginalDensity.LaplaceApproximation)
skipline()
end
if options_.dsge_var

@ -1 +1 @@
Subproject commit 06bae2c377221256dfd0d237685f528c3c710374
Subproject commit 1bb3b1cbc9d1b29136e8e533d871e247f1b11103

View File

@ -130,7 +130,7 @@ for k=1:nvar
for draws = 1:ndraws1
if ~mod(draws,nbuffer)
skipline()
disp(sprintf('The %dth column or equation in A0 with %d 1st tossed-away draws in Gibbs',k,draws))
dprintf('The %dth column or equation in A0 with %d 1st tossed-away draws in Gibbs', k, draws)
end
A0gbs1 = fn_gibbsrvar(A0gbs0,UT,nvar,fss,n0,indx_ks);
A0gbs0=A0gbs1; % repeat the Gibbs sampling
@ -141,7 +141,7 @@ for k=1:nvar
for draws = 1:ndraws2
if ~mod(draws,nbuffer)
skipline()
disp(sprintf('The %dth column or equation in A0 with %d usable draws in Gibbs',k,draws))
dprintf('The %dth column or equation in A0 with %d usable draws in Gibbs', k, draws)
end
[A0gbs1, Wcell] = fn_gibbsrvar(A0gbs0,UT,nvar,fss,n0,indx_ks);
%------ See p.71, Forecast (II).
@ -163,7 +163,7 @@ for k=1:nvar
% The log value of p(a0_k|Y,a_others) where a_others: other a's at some point such as the peak of ONLY some a0's
else
skipline()
disp(sprintf('The last(6th) column or equation in A0 with no Gibbs draws'))
disp('The last(6th) column or equation in A0 with no Gibbs draws')
[A0gbs1, Wcell] = fn_gibbsrvar(A0gbs0,UT,nvar,fss,n0,indx_ks)
%------ See p.71, Forecast (II).
%------ Computing p(a0_k|Y,a_others) at some point such as the peak along the dimensions of indx_ks.

View File

@ -1739,7 +1739,7 @@ while irun <= myeval(opts.Restarts) % for-loop does not work with resume
if N < 102
disp(['mean solution:' sprintf(' %+.1e', xmean)]);
disp(['std deviation:' sprintf(' %.1e', sigma*sqrt(diagC))]);
disp(sprintf('use plotcmaesdat.m for plotting the output at any time (option LogModulo must not be zero)'));
dprintf('use plotcmaesdat.m for plotting the output at any time (option LogModulo must not be zero)');
end
if exist('sfile', 'var')
disp(['Results saved in ' sfile]);

View File

@ -384,19 +384,19 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
fval_(1:length(fval)) = fval;
if isfinite(fv(end)) && isfinite(fv(1))
if fv(end)<0
disp(sprintf('%s %s %12.7E %12.7E %12.7E %12.7E %s', iter_, fval_, fv(1), fv(end), critF, critX, move))
dprintf('%s %s %12.7E %12.7E %12.7E %12.7E %s', iter_, fval_, fv(1), fv(end), critF, critX, move)
else
if fv(1)>0
disp(sprintf('%s %s %12.7E %12.7E %12.7E %12.7E %s', iter_, fval_, fv(1), fv(end), critF, critX, move))
dprintf('%s %s %12.7E %12.7E %12.7E %12.7E %s', iter_, fval_, fv(1), fv(end), critF, critX, move)
else
disp(sprintf('%s %s %12.7E %12.7E %12.7E %12.7E %s', iter_, fval_, fv(1), fv(end), critF, critX, move))
dprintf('%s %s %12.7E %12.7E %12.7E %12.7E %s', iter_, fval_, fv(1), fv(end), critF, critX, move)
end
end
else
if isfinite(fv(1))
disp(sprintf(['%s %s %12.7E %12.7E %s'], iter_, fval_, fv(1) , critX, move))
dprintf(['%s %s %12.7E %12.7E %s'], iter_, fval_, fv(1) , critX, move)
else
disp(sprintf('%s %s %12.7E %s', iter_, fval_, critX, move))
dprintf('%s %s %12.7E %s', iter_, fval_, critX, move)
end
end
end
@ -551,4 +551,4 @@ for j = 1:n
end
% Sort by increasing order of the objective function values.
[fv,sort_idx] = sort(fv);
v = v(:,sort_idx);
v = v(:,sort_idx);

View File

@ -264,7 +264,7 @@ while 1
if nITERATIONS == 0
disp(' Nr Iter Nr Fun Eval Min function Best function TEMP Algorithm Step');
else
disp(sprintf('%5.0f %5.0f %12.6g %15.6g %12.6g %s',nITERATIONS,nFUN_EVALS,Y(1),YBEST,TEMP,'best point'));
dprintf('%5.0f %5.0f %12.6g %15.6g %12.6g %s',nITERATIONS,nFUN_EVALS,Y(1),YBEST,TEMP,'best point');
end
end
@ -319,7 +319,7 @@ while 1
end
if strcmp(OPTIONS.DISPLAY,'iter')
disp(sprintf('%5.0f %5.0f %12.6g %15.6g %12.6g %s',nITERATIONS,nFUN_EVALS,Y(1),YBEST,TEMP,ALGOSTEP));
dprintf('%5.0f %5.0f %12.6g %15.6g %12.6g %s',nITERATIONS,nFUN_EVALS,Y(1),YBEST,TEMP,ALGOSTEP);
end
% if output function given then run output function to plot intermediate result

View File

@ -48,7 +48,7 @@ else
end
if options_.verbosity
printline(41)
disp(sprintf('MODEL SIMULATION (method=%s):',mthd))
dprintf('MODEL SIMULATION (method=%s):', mthd)
skipline()
end

View File

@ -126,5 +126,4 @@ switch (extension)
end
cd(old_pwd)
disp(sprintf('Loading %d observations from %s\n',...
size(dyn_data_01,1),fullname))
dprintf('Loading %d observations from %s', size(dyn_data_01, 1), fullname)