fixed bug in drawing of prior densities (It must always return
'steps' values)time-shift
parent
b58eaa8e2b
commit
074515bfc2
|
@ -45,8 +45,7 @@ switch pshape(indx)
|
||||||
density = @(x,a,b,aa,bb) betapdf((x-aa)/(bb-aa), a, b)/(bb-aa);
|
density = @(x,a,b,aa,bb) betapdf((x-aa)/(bb-aa), a, b)/(bb-aa);
|
||||||
infbound = betainv(truncprior,p6(indx),p7(indx))*(p4(indx)-p3(indx))+p3(indx);
|
infbound = betainv(truncprior,p6(indx),p7(indx))*(p4(indx)-p3(indx))+p3(indx);
|
||||||
supbound = betainv(1-truncprior,p6(indx),p7(indx))*(p4(indx)-p3(indx))+p3(indx);
|
supbound = betainv(1-truncprior,p6(indx),p7(indx))*(p4(indx)-p3(indx))+p3(indx);
|
||||||
stepsize = (supbound-infbound)/steps;
|
abscissa = linspace(infbound,supbound,steps);
|
||||||
abscissa = infbound:stepsize:supbound;
|
|
||||||
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);
|
||||||
|
@ -61,14 +60,12 @@ switch pshape(indx)
|
||||||
rethrow(lasterror)
|
rethrow(lasterror)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
stepsize = (supbound-infbound)/steps;
|
abscissa = linspace(infbound,supbound,steps);
|
||||||
abscissa = infbound:stepsize:supbound;
|
|
||||||
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
|
||||||
infbound = norminv(truncprior,p6(indx),p7(indx));
|
infbound = norminv(truncprior,p6(indx),p7(indx));
|
||||||
supbound = norminv(1-truncprior,p6(indx),p7(indx));
|
supbound = norminv(1-truncprior,p6(indx),p7(indx));
|
||||||
stepsize = (supbound-infbound)/steps;
|
abscissa = linspace(infbound,supbound,steps);
|
||||||
abscissa = infbound:stepsize:supbound;
|
|
||||||
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
|
try
|
||||||
|
@ -82,14 +79,12 @@ switch pshape(indx)
|
||||||
rethrow(lasterror)
|
rethrow(lasterror)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
stepsize = (supbound-infbound)/steps;
|
abscissa = linspace(infbound,supbound,steps);
|
||||||
abscissa = infbound:stepsize:supbound;
|
|
||||||
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
|
||||||
infbound = p6(indx);
|
infbound = p6(indx);
|
||||||
supbound = p7(indx);
|
supbound = p7(indx);
|
||||||
stepsize = (supbound-infbound)/steps;
|
abscissa = linspace(infbound,supbound,steps);
|
||||||
abscissa = infbound:stepsize:supbound;
|
|
||||||
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
|
try
|
||||||
|
@ -103,23 +98,22 @@ switch pshape(indx)
|
||||||
rethrow(lasterror)
|
rethrow(lasterror)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
stepsize = (supbound-infbound)/steps ;
|
abscissa = linspace(infbound,supbound,steps);
|
||||||
abscissa = infbound:stepsize:supbound;
|
|
||||||
dens = exp(lpdfig2(abscissa-p3(indx),p6(indx),p7(indx)));
|
dens = exp(lpdfig2(abscissa-p3(indx),p6(indx),p7(indx)));
|
||||||
otherwise
|
otherwise
|
||||||
error(sprintf('draw_prior_density: unknown distribution shape (index %d, type %d)', indx, pshape(indx)));
|
error(sprintf('draw_prior_density: unknown distribution shape (index %d, type %d)', indx, pshape(indx)));
|
||||||
end
|
end
|
||||||
|
|
||||||
k = [1:length(dens)];
|
|
||||||
if pshape(indx) ~= 5
|
if pshape(indx) ~= 5
|
||||||
[junk,k1] = max(dens);
|
[junk,k1] = max(dens);
|
||||||
if k1 == 1 || k1 == length(dens)
|
if k1 == 1 || k1 == length(dens)
|
||||||
k = find(dens < 10);
|
k = find(dens > 10);
|
||||||
|
dens(k) = NaN;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
binf = abscissa(k(1));
|
binf = abscissa(1);
|
||||||
bsup = abscissa(k(length(k)));
|
bsup = abscissa(end);
|
||||||
x = abscissa(k);
|
x = abscissa;
|
||||||
f = dens(k);
|
f = dens;
|
||||||
f(find(x<bayestopt_.lb(indx)))=0;
|
f(find(x<bayestopt_.lb(indx)))=0;
|
||||||
f(find(x>bayestopt_.ub(indx)))=0;
|
f(find(x>bayestopt_.ub(indx)))=0;
|
Loading…
Reference in New Issue