limda_est.asv
上传用户:doryuen
上传日期:2013-10-30
资源大小:23k
文件大小:3k
源码类别:

通讯/手机编程

开发平台:

Matlab

  1. function limda=limda_est(A,b,p,q)
  2. %
  3. %
  4. %
  5.  
  6. %         M=1e6; cn=0;
  7. %         for t=M:1:5*M
  8. %             cn=cn+1;
  9. %               f(cn)=q'*inv(A'*A+t*p)*(A'*b-0.5*t*q)+(inv(A'*A+t*p)*(A'*b-0.5*t*q))'*p*inv(A'*A+t*p)*(A'*b-0.5*t*q);
  10. %         end
  11. %         t=M:1:5*M;
  12.         
  13.         
  14.  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  15.             M=1e7;
  16.           inter=[0 M];
  17.           err=inf;
  18.           au=[];bu=[];
  19.           au=inter(1);bu=inter(2);
  20.           num=0;
  21.           while err> 1e-4 && num<1e4
  22.               num=num+1;
  23.               fau=q'*inv(A'*A+au*p)*(A'*b-0.5*au*q)+(inv(A'*A+au*p)*(A'*b-0.5*au*q))'*p*inv(A'*A+au*p)*(A'*b-0.5*au*q);
  24.               fbu=q'*inv(A'*A+bu*p)*(A'*b-0.5*bu*q)+(inv(A'*A+bu*p)*(A'*b-0.5*bu*q))'*p*inv(A'*A+bu*p)*(A'*b-0.5*bu*q);
  25.               if fau*fbu<0
  26.                   cu=(au+bu)/2;
  27.                   fcu=q'*inv(A'*A+cu*p)*(A'*b-0.5*cu*q)+(inv(A'*A+cu*p)*(A'*b-0.5*cu*q))'*p*inv(A'*A+cu*p)*(A'*b-0.5*cu*q);
  28.                   if fcu<0
  29.                       au=cu;
  30.                   else
  31.                       bu=cu;
  32.                   end
  33.               end
  34.               err=abs(au-bu);
  35.           end
  36.           
  37.         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  38. %             step=1e3;
  39. %             flag=0;
  40. %             down=-1e7;
  41. %             while flag==0
  42. %                 fdown=q'*inv(A'*A+down*p)*(A'*b-0.5*down*q)+(inv(A'*A+down*p)*(A'*b-0.5*down*q))'*p*inv(A'*A+down*p)*(A'*b-0.5*down*q);
  43. %                 up=down+step;
  44. %                 fup=q'*inv(A'*A+up*p)*(A'*b-0.5*up*q)+(inv(A'*A+up*p)*(A'*b-0.5*up*q))'*p*inv(A'*A+up*p)*(A'*b-0.5*up*q);
  45. %                 if fdown*fup<0
  46. %                     flag=1;
  47. %                 end
  48. %                 if fdown*fup>0
  49. %                     down=down+step;
  50. %                     up=down+step;
  51. %                 end                
  52. %             end
  53.         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  54.         
  55.           inter=[-M 0];
  56.           err=inf;
  57.           au=[];bu=[];
  58.           au=inter(1);bu=inter(2);
  59.           num=0;
  60.           while err> 1e-4 && num<1e4
  61.               num=num+1;
  62.               
  63.               fau=q'*inv(A'*A+au*p)*(A'*b-0.5*au*q)+(inv(A'*A+au*p)*(A'*b-0.5*au*q))'*p*inv(A'*A+au*p)*(A'*b-0.5*au*q);
  64.               fbu=q'*inv(A'*A+bu*p)*(A'*b-0.5*bu*q)+(inv(A'*A+bu*p)*(A'*b-0.5*bu*q))'*p*inv(A'*A+bu*p)*(A'*b-0.5*bu*q);
  65.               if fau*fbu<0
  66.                   cu=(au+bu)/2;
  67.                   fcu=q'*inv(A'*A+cu*p)*(A'*b-0.5*cu*q)+(inv(A'*A+cu*p)*(A'*b-0.5*cu*q))'*p*inv(A'*A+cu*p)*(A'*b-0.5*cu*q);
  68.                   if fcu<0
  69.                       bu=cu;
  70.                   else
  71.                       au=cu;
  72.                   end
  73.               end
  74.               err=abs(au-bu);
  75.           end
  76.           limda=cu;        
  77.  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  78.             6;