Home > . > draw_prior_density.m

draw_prior_density

PURPOSE ^

stephane.adjemian@ens.fr [07-15-2004]

SYNOPSIS ^

function [x,f,abscissa,dens,binf,bsup] = draw_prior_density(indx);

DESCRIPTION ^

 stephane.adjemian@ens.fr [07-15-2004]

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [x,f,abscissa,dens,binf,bsup] = draw_prior_density(indx);
0002 % stephane.adjemian@ens.fr [07-15-2004]
0003 
0004 global bayestopt_
0005 
0006 pmean   = bayestopt_.pmean;
0007 pshape  = bayestopt_.pshape; 
0008 p1      = bayestopt_.p1;
0009 p2      = bayestopt_.p2;
0010 p3      = bayestopt_.p3;
0011 p4      = bayestopt_.p4;
0012 
0013 truncprior = 10^(-3);
0014 
0015 if pshape(indx) == 1     %/* BETA Prior */
0016     density = inline('((bb-x).^(b-1)).*(x-aa).^(a-1)./(beta(a,b)*(bb-aa)^(a+b-1))','x','a','b','aa','bb');
0017     mu = (p1(indx)-p3(indx))/(p4(indx)-p3(indx));
0018     stdd = p2(indx)/(p4(indx)-p3(indx));
0019     a = (1-mu)*mu^2/stdd^2 - mu;
0020     b = a*(1/mu-1);
0021     aa = p3(indx);
0022     bb = p4(indx);
0023     infbound = qbeta(truncprior,a,b)*(bb-aa)+aa;
0024     supbound = qbeta(1-truncprior,a,b)*(bb-aa)+aa;
0025     stepsize = (supbound-infbound)/200;
0026     abscissa = infbound:stepsize:supbound;
0027     dens = density(abscissa,a,b,aa,bb);
0028 elseif pshape(indx) == 2  %/* GAMMA PRIOR */
0029     mu = p1(indx)-p3(indx);
0030     b  = p2(indx)^2/mu;
0031     a  = mu/b;
0032     infbound = mj_qgamma(truncprior,a)*b; 
0033     supbound = mj_qgamma(1-truncprior,a)*b;
0034     stepsize = (supbound-infbound)/200;
0035     abscissa = infbound:stepsize:supbound;
0036     dens = exp(lpdfgam(abscissa,a,b));
0037     abscissa = abscissa + p3(indx);
0038 elseif pshape(indx) == 3  %/* GAUSSIAN PRIOR */
0039     density = inline('inv(sqrt(2*pi)*b)*exp(-0.5*((x-a)/b).^2)','x','a','b');
0040     a = p1(indx);
0041     b = p2(indx);
0042     infbound = qnorm(truncprior,a,b); 
0043     supbound = qnorm(1-truncprior,a,b);
0044     stepsize = (supbound-infbound)/200;
0045     abscissa = infbound:stepsize:supbound;
0046     dens = density(abscissa,a,b);  
0047 elseif pshape(indx) == 4  %/* INVGAMMA PRIOR type 1 */
0048     density = inline('2*inv(gamma(nu/2))*(x.^(-nu-1))*((s/2)^(nu/2)).*exp(-s./(2*x.^2))','x','s','nu');
0049     nu = p2(indx);
0050     s  = p1(indx);
0051     a  = nu/2;
0052     b  = 2/s;
0053     infbound = 1/sqrt(mj_qgamma(1-10*truncprior,a)*b); 
0054     supbound = 1/sqrt(mj_qgamma(10*truncprior,a)*b);
0055     stepsize = (supbound-infbound)/200;
0056     abscissa = infbound:stepsize:supbound;
0057     dens = density(abscissa,s,nu);  
0058 elseif pshape(indx) == 5  %/* UNIFORM PRIOR */
0059     density = inline('(x.^0)/(b-a)','x','a','b');
0060     a  = p1(indx);
0061     b  = p2(indx);
0062     infbound = a; 
0063     supbound = b;
0064     stepsize = (supbound-infbound)/200;
0065     abscissa = infbound:stepsize:supbound;
0066     dens = density(abscissa,a,b);  
0067 elseif pshape(indx) == 6  %/*  INVGAMMA PRIOR type 2 */
0068     density = inline('inv(gamma(nu/2))*(x.^(-.5(nu+2)))*((s/2)^(nu/2)).*exp(-s./(2*x))','x','s','nu');
0069     nu = p2(indx);
0070     s  = p1(indx);
0071     a  = nu/2;
0072     b  = 2/s;
0073     infbound = 1/(qgamma(1-truncprior,a)*b); 
0074     supbound = 1/(qgamma(truncprior,a)*b);
0075     stepsize = (supbound-infbound)/200;
0076     abscissa = infbound:stepsize:supbound;
0077     dens = density(abscissa,s,nu);  
0078 end 
0079 
0080 k = [1:length(dens)];
0081 if pshape(indx) ~= 5 
0082     [junk,k1] = max(dens);
0083     if k1 == 1 | k1 == length(dens)
0084         k = find(dens < 10);
0085     end
0086 end
0087 binf = abscissa(k(1));
0088 bsup = abscissa(k(length(k)));
0089 x = abscissa(k);
0090 f = dens(k);

Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003