limda_est.m
上传用户: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=5*1e3;
  39.             flag=0;
  40.             down=-1e10; nf=0;
  41.             while flag==0
  42.                 nf=nf+1
  43.                 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);
  44.                 up=down+step;
  45.                 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);
  46.                 if fdown*fup<0
  47.                     flag=1;
  48.                 end
  49.                 if fdown*fup>0
  50.                     down=down+step;
  51.                     up=down+step;
  52.                 end                
  53.             end
  54.         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  55.         
  56.           inter=[down up];
  57. %           inter=[-M 0];
  58.           err=inf;
  59.           au=[];bu=[];
  60.           au=inter(1);bu=inter(2);
  61.           num=0;
  62.           while err> 1e-4 && num<1e4
  63.               num=num+1;
  64.               
  65.               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);
  66.               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);
  67.               if fau*fbu<0
  68.                   cu=(au+bu)/2;
  69.                   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);
  70.                   if fcu<0
  71.                       bu=cu;
  72.                   else
  73.                       au=cu;
  74.                   end
  75.               end
  76.               err=abs(au-bu);
  77.           end
  78.           limda=cu;        
  79.  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  80.             6;