MINDIST Finds minimal distance to the origin on the surface b'*x+x'*diag(g)*x=u CALL: xstar=mindist(g,b,u,n0,eps); u = levels n0 = number of non zero elements in the starting point eps = accuracy in the iteration Iterative solution to the problem om finding the point of minimal distance to origin on the surface b'*x+x'*diag(g)*x=u, where x0 is the starting value.
Finds point of minimal distance to the origin on the surface b'*x+g'*x.^2=u. | |
Convert integer to string (Fast version). | |
Display warning message; disable or enable warning messages. |
SORM-approximation of the crossing intensity for the noncentral Chi^2 process | |
Gives first two terms in an asymptotic expansion of the |
001 function xstar=mindist(g,b,u,n0,epsi) 002 % MINDIST Finds minimal distance to the origin on the surface b'*x+x'*diag(g)*x=u 003 % 004 % CALL: xstar=mindist(g,b,u,n0,eps); 005 % 006 % u = levels 007 % n0 = number of non zero elements in the starting point 008 % eps = accuracy in the iteration 009 % 010 % Iterative solution to the problem om finding the point of minimal 011 % distance to origin on the surface b'*x+x'*diag(g)*x=u, where x0 012 % is the starting value. 013 014 015 if nargin<5 016 epsi=1e-12; 017 end 018 niter=1000; 019 iter=1; 020 n1=length(g); 021 n0=min(n1,n0); 022 xstar=mindist3(g(end-n0+1:end),b(end-n0+1:end),u); 023 if n0<n1 024 xn=[zeros(n1-n0,1);xstar]; 025 b=b(:); 026 g=g(:); 027 xnold=xn+1; 028 while iter<niter&sum(abs(xn-xnold))>epsi 029 a=1-b'*xn/u-g'*xn.^2/u; 030 A=-b/u-2*g.*xn/u; 031 xnold=xn; 032 xn=(A'*xn-a)/(A'*A)*A; 033 iter=iter+1; 034 end 035 xstar=xn; 036 if iter==niter 037 warning(['The algorithm didn''t converged after ' int2str(niter) 'times for level u=' int2str(u)]) 038 end 039 end 040 041 042 043
Comments or corrections to the WAFO group