% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
ifnargin<3
lb=0;
ub=1;
end
ifnargin<4
ub=1;
end
ifnargin>4&&~isempty(name)
name1=sprintf('of %s ',name);
name2=sprintf(' (for %s)',name);
else
name1='';
name2='';
end
ifmu<lb
error(['The prior expectation (%f) %scannot be smaller than the lower bound of the Beta distribution (%f)!'],mu,name1,lb)
end
ifmu>ub
error('The prior expectation (%f) %scannot be greater than the upper bound of the Beta distribution (%f)!',mu,name1,ub)
end
len=ub-lb;
mu=(mu-lb)/len;
sigma2=sigma2/(len*len);
ifsigma2>(1-mu)*mu
error('Beta prior%s. Given the declared prior expectation, prior lower and upper bounds, the prior std. has to be smaller than %f.',name2,sqrt((1-mu)*mu))