⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 golden.m

📁 这是在网上下的一个东东
💻 M
字号:
%%%%%%%%%% start of function golden.m %%%%%%%%%%%% Function to perform a Golden section search to calculate %           optimal step length%% Written by: Roseanna M. Neupauer% Modification Date: April 24, 1999% Modification Date: June 25, 1999 (added option to use additive noise,%		multiplicative noise, or a combination of the two)%% alpha=golden(funfcn,lambda,dellame,tolls,g,beta,upper,...%          csample,noise,nearzero,large)% Inputs%     funfcn       name of matlab function that calculates the %                    F vector (Equation 2.28) funfcn='getfk'%     lambda       array containing the Lagrange multipliers%     dellame      step direction%     tolls        tolerance for golden section search%     g            matrix of scaled kernel functions%     beta         array of Lagrange multipliers, beta%     upper        array containing upper limit of prior %                    distributions%     csample      array containing sampled concentrations%     noise        vector of noise levels:%			1. standard deviation of normally-distributed %                    	additive random noise in measurements;%			2. standard deviation of normally-distributed %                    	multiplicative random noise in measurements;%     nearzero     value below which the asymptotic %                    approximation to zero is used%     large        value above which the asymptotic %                    approximation to infinity is used%% Outputs%     alpha        optimal step length%% Functions called%     getfk        calculates the F vectorfunction alpha=golden(funfcn,lambda,dellame,tolls,g,beta,...          upper,csample,noise,nearzero,large)% bracket the step length to within a .1-length intervalnormdel=ones(11,1);for brack=1:11     del=0.1*(brack-1);     [newfe,dummy,dummy1]=feval(funfcn,lambda+del*dellame,...          g,beta,upper,csample,noise,nearzero,large);     normdel(brack)=norm(newfe);endminbrack=find(normdel==min(normdel));minbrack=minbrack(1);if (minbrack >=  10)     aa=0.9;     bb=1.0;elseif (minbrack <= 2)     aa=0.;     bb=0.1;          else     aa=0.1*(minbrack-1);     bb=0.1*(minbrack+1);end% Using the 0.1-length interval as a starting interval, %     perform a Golden section search in the step direction[newfe,dummy,dummy1]=feval(funfcn,lambda+aa*dellame,g,beta,...     upper,csample,noise,nearzero,large);fa=norm(newfe);[newfe,dummy,dummy1]=feval(funfcn,lambda+bb*dellame,g,beta,...     upper,csample,noise,nearzero,large);fb=norm(newfe);tau=2/(1+sqrt(5));F1=aa+(1-tau)*(bb-aa);F2=aa+tau*(bb-aa);[newfe,dummy,dummy1]=feval(funfcn,lambda+F1*dellame,g,beta,...     upper,csample,noise,nearzero,large);fF1=norm(newfe);[newfe,dummy,dummy1]=feval(funfcn,lambda+F2*dellame,g,beta,...     upper,csample,noise,nearzero,large);fF2=norm(newfe);while abs(F1-F2) > tolls     if (fF1 > fF2 & fa > fF1)          aa=F1;          temp=F2;          F1=F2;          fF1=fF2;          F2=temp+tau*(bb-temp);          [newfe,dummy,dummy1]=feval(funfcn,...               lambda+F2*dellame,g,beta,upper,...               csample,noise,nearzero,large);          fF2=norm(newfe);     else          bb=F2;          temp=F1;          F2=F1;          fF2=fF1;          F1=aa+(1-tau)*(temp-aa);          [newfe,dummy,dummy1]=feval(funfcn,...               lambda+F1*dellame,g,beta,upper,...               csample,noise,nearzero,large);          fF1=norm(newfe);     endendalpha=(F1+F2)/2;return%%%%%%%%%%  end of function golden.m  %%%%%%%%%%

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -