Skip to content
Snippets Groups Projects
Verified Commit 4b4c9abb authored by Sébastien Villemot's avatar Sébastien Villemot Committed by Stéphane Adjemian
Browse files

Remove workaround for gaminv() bug fixed in Octave 4.4

parent 24892bd6
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ function [x,f,abscissa,dens,binf,bsup] = draw_prior_density(indx,bayestopt_) ...@@ -14,7 +14,7 @@ function [x,f,abscissa,dens,binf,bsup] = draw_prior_density(indx,bayestopt_)
% bsup: [double] Scalar, last element of x % bsup: [double] Scalar, last element of x
% Copyright © 2004-2017 Dynare Team % Copyright © 2004-2023 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -49,17 +49,8 @@ switch pshape(indx) ...@@ -49,17 +49,8 @@ switch pshape(indx)
dens = density(abscissa,p6(indx),p7(indx),p3(indx),p4(indx)); dens = density(abscissa,p6(indx),p7(indx),p3(indx),p4(indx));
case 2% Generalized Gamma prior case 2% Generalized Gamma prior
density = @(x,a,b,c) gampdf(x-c,a,b); density = @(x,a,b,c) gampdf(x-c,a,b);
try
infbound = gaminv(truncprior,p6(indx),p7(indx))+p3(indx); infbound = gaminv(truncprior,p6(indx),p7(indx))+p3(indx);
supbound = gaminv(1-truncprior,p6(indx),p7(indx))+p3(indx); supbound = gaminv(1-truncprior,p6(indx),p7(indx))+p3(indx);
catch
% Workaround for ticket #161, see http://savannah.gnu.org/bugs/?52569
if isoctave
error(['Due to a computational limitation in Octave, the prior cannot be plotted. You must either use plot_priors=0 or choose other values for mean and/or variance of your prior on ' bayestopt_.name{indx} ', or use another shape'])
else
rethrow(lasterror)
end
end
abscissa = linspace(infbound,supbound,steps); abscissa = linspace(infbound,supbound,steps);
dens = density(abscissa,p6(indx),p7(indx),p3(indx)); dens = density(abscissa,p6(indx),p7(indx),p3(indx));
case 3% Gaussian prior case 3% Gaussian prior
...@@ -68,17 +59,8 @@ switch pshape(indx) ...@@ -68,17 +59,8 @@ switch pshape(indx)
abscissa = linspace(infbound,supbound,steps); abscissa = linspace(infbound,supbound,steps);
dens = normpdf(abscissa,p6(indx),p7(indx)); dens = normpdf(abscissa,p6(indx),p7(indx));
case 4% Inverse-gamma of type 1 prior case 4% Inverse-gamma of type 1 prior
try
infbound = 1/sqrt(gaminv(1-10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx); infbound = 1/sqrt(gaminv(1-10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx);
supbound = 1/sqrt(gaminv(10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx); supbound = 1/sqrt(gaminv(10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx);
catch
% Workaround for ticket #161, see http://savannah.gnu.org/bugs/?52569
if isoctave
error(['Due to a computational limitation in Octave, the prior cannot be plotted. You must either use plot_priors=0 or choose other values for mean and/or variance of your prior on ' bayestopt_.name{indx} ', or use another shape'])
else
rethrow(lasterror)
end
end
abscissa = linspace(infbound,supbound,steps); abscissa = linspace(infbound,supbound,steps);
dens = exp(lpdfig1(abscissa-p3(indx),p6(indx),p7(indx))); dens = exp(lpdfig1(abscissa-p3(indx),p6(indx),p7(indx)));
case 5% Uniform prior case 5% Uniform prior
...@@ -87,17 +69,8 @@ switch pshape(indx) ...@@ -87,17 +69,8 @@ switch pshape(indx)
abscissa = linspace(infbound,supbound,steps); abscissa = linspace(infbound,supbound,steps);
dens = ones(1, steps) / (supbound-infbound); dens = ones(1, steps) / (supbound-infbound);
case 6% Inverse-gamma of type 2 prior case 6% Inverse-gamma of type 2 prior
try
infbound = 1/(gaminv(1-10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx); infbound = 1/(gaminv(1-10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx);
supbound = 1/(gaminv(10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx); supbound = 1/(gaminv(10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx);
catch
% Workaround for ticket #161, see http://savannah.gnu.org/bugs/?52569
if isoctave
error(['Due to a computational limitation in Octave, the prior cannot be plotted. You must either use plot_priors=0 or choose other values for mean and/or variance of your prior on ' bayestopt_.name{indx} ', or use another shape'])
else
rethrow(lasterror)
end
end
abscissa = linspace(infbound,supbound,steps); abscissa = linspace(infbound,supbound,steps);
dens = exp(lpdfig2(abscissa-p3(indx),p6(indx),p7(indx))); dens = exp(lpdfig2(abscissa-p3(indx),p6(indx),p7(indx)));
case 8 case 8
......
...@@ -47,7 +47,7 @@ function bounds = prior_bounds(bayestopt, prior_trunc) ...@@ -47,7 +47,7 @@ function bounds = prior_bounds(bayestopt, prior_trunc)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright © 2003-2017 Dynare Team % Copyright © 2003-2023 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -88,17 +88,8 @@ for i=1:length(p6) ...@@ -88,17 +88,8 @@ for i=1:length(p6)
bounds.lb(i) = p3(i); bounds.lb(i) = p3(i);
bounds.ub(i) = Inf; bounds.ub(i) = Inf;
else else
try
bounds.lb(i) = gaminv(prior_trunc,p6(i),p7(i))+p3(i); bounds.lb(i) = gaminv(prior_trunc,p6(i),p7(i))+p3(i);
bounds.ub(i) = gaminv(1-prior_trunc,p6(i),p7(i))+p3(i); bounds.ub(i) = gaminv(1-prior_trunc,p6(i),p7(i))+p3(i);
catch
% Workaround for ticket #161, see http://savannah.gnu.org/bugs/?52569
if isoctave
error(['Due to a computational limitation in Octave, the prior bounds cannot be computed. You must either use prior_trunc=0 or choose other values for mean and/or variance of your prior on ' bayestopt.name{i} ', or use another shape'])
else
rethrow(lasterror)
end
end
end end
case 3 case 3
if prior_trunc == 0 if prior_trunc == 0
...@@ -113,17 +104,8 @@ for i=1:length(p6) ...@@ -113,17 +104,8 @@ for i=1:length(p6)
bounds.lb(i) = p3(i); bounds.lb(i) = p3(i);
bounds.ub(i) = Inf; bounds.ub(i) = Inf;
else else
try
bounds.lb(i) = 1/sqrt(gaminv(1-prior_trunc, p7(i)/2, 2/p6(i)))+p3(i); bounds.lb(i) = 1/sqrt(gaminv(1-prior_trunc, p7(i)/2, 2/p6(i)))+p3(i);
bounds.ub(i) = 1/sqrt(gaminv(prior_trunc, p7(i)/2, 2/p6(i)))+p3(i); bounds.ub(i) = 1/sqrt(gaminv(prior_trunc, p7(i)/2, 2/p6(i)))+p3(i);
catch
% Workaround for ticket #161, see http://savannah.gnu.org/bugs/?52569
if isoctave
error(['Due to a computational limitation in Octave, the prior bounds cannot be computed. You must either use prior_trunc=0 or choose other values for mean and/or variance of your prior on ' bayestopt.name{i} ', or use another shape'])
else
rethrow(lasterror)
end
end
end end
case 5 case 5
if prior_trunc == 0 if prior_trunc == 0
...@@ -138,17 +120,8 @@ for i=1:length(p6) ...@@ -138,17 +120,8 @@ for i=1:length(p6)
bounds.lb(i) = p3(i); bounds.lb(i) = p3(i);
bounds.ub(i) = Inf; bounds.ub(i) = Inf;
else else
try
bounds.lb(i) = 1/gaminv(1-prior_trunc, p7(i)/2, 2/p6(i))+p3(i); bounds.lb(i) = 1/gaminv(1-prior_trunc, p7(i)/2, 2/p6(i))+p3(i);
bounds.ub(i) = 1/gaminv(prior_trunc, p7(i)/2, 2/p6(i))+ p3(i); bounds.ub(i) = 1/gaminv(prior_trunc, p7(i)/2, 2/p6(i))+ p3(i);
catch
% Workaround for ticket #161, see http://savannah.gnu.org/bugs/?52569
if isoctave
error(['Due to a computational limitation in Octave, the prior bounds cannot be computed. You must either use prior_trunc=0 or choose other values for mean and/or variance of your prior on ' bayestopt.name{i} ', or use another shape'])
else
rethrow(lasterror)
end
end
end end
case 8 case 8
if prior_trunc == 0 if prior_trunc == 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment