Presentation is loading. Please wait.

Presentation is loading. Please wait.

Least Squares. 给定一组测量或观测值 假设 y 是 n 个函数的线性组合 设 m×n 矩阵 X 定义为 所以 β=X\y.

Similar presentations


Presentation on theme: "Least Squares. 给定一组测量或观测值 假设 y 是 n 个函数的线性组合 设 m×n 矩阵 X 定义为 所以 β=X\y."— Presentation transcript:

1 Least Squares

2 给定一组测量或观测值 假设 y 是 n 个函数的线性组合 设 m×n 矩阵 X 定义为 所以 β=X\y

3 直线: 多项式: 有理函数: 指数:

4 Log-linear: Gaussians:

5 p = 1e4*[ ]'; t = (1949:1:2005)'; x = (1940: 0.2 :2019)'; w = 2010; d = 3; s = (t-1979)/30; c = polyfit(s,p,d); s = (x-1979)/30; y = polyval(c,s); s = (w-1979)/30; z = polyval(c,s); plot(t,p,'o',x,y,'b-',w,z,'r*') s = (t-1979)/30; c = polyfit(s,p,3); X = [s.^3, s.^2, s, ones(length(s),1)]; X\p 中国人口预测

6

7 1 、求逆的过程困难 2 、

8 写成矩阵形式为: 其中,

9

10

11 Matlab 中避免用法方程求解 QR 分解: Q 正交阵 (orthogonal) R 上三角阵 求解:

12 s: X: y:

13 u(1) = u(1) + sigma; rho = 1/( sigma *u(1)); X(i,k) = 0; X(k,k) = -sigma; j = k+1:n; v = rho*(u'* X(i,j)); X(i,j) = X(i,j) - u*v; if ~isempty(y) tau = rho*(u'* y(i)); y(i) = y(i) - tau*u; end beta = X(1:n,1:n)\y(1:n) polyval(beta,( )/30) s = ( (1950:10:2000)'-1979 )/30; X = [s.^2, s, ones(size(s),1)] y = [ ] [m,n] = size(X); for k = 1:min(m-1,n) i = k:m; u = X(i,k); sigma = norm(u); if sigma ~= 0 if u(1) ~= 0, sigma = sign(u(1))*sigma; end u(1) = u(1) + sigma; rho = 1/( sigma *u(1));

14 X = y = 1.0e+005 * X = y = 1.0e+005 * X = y = 1.0e+005 *

15 列满秩 是左逆 不是右逆, 但满足 广义逆

16 X = 秩亏损 (Rank Deficiency) 接近秩亏损 X\y ans = pinv(X)*y ans = X\y-pinv(X)*y ans = y =

17 非线性最小二乘问题 fminsearch fmincon fminunc lsqnonlin lsqcurvefit

18 dbstop at 14 in xxx %F12 dbquit dbtype xxx.m 12:15 %type,edit error(‘xxxxx’) pause(n) keyboard; %K>>return 调试

19

20 分块循环约化( Block cyclic reduction ) 求解矩形域上的 Poisson 方程,产生如下的系数矩阵: 用分块循环约化法求 (假设解全为 1 ) 比较分块循环约化与通常求解方法的效率。 参考 G. H. Golub, C. F. Van Loan, Matrix Computations, 3 rd ed., Johns Hopkins University Press, Baltimore and London, 有中文版, p.202

21 Solve 1. Block cyclic reduction (BCR) B. L. Buzbee, G. H. Golub, C.W. Nielson, On direct methods for solving Poisson ’ s equations, SIAM J. Numer. Anal., 7(1970), pp Block orthogonal factorization (BOF) G. Fairweather, I. Gladwell, Algorithms for almost block diagonal linear systems, SIAM Review, 46(2004), pp S. J. Wright, Stable parallel algorithms for two-point boundary value problem, SIAM J. Sci. Statist. Comput., 13(1992), pp 进一步探讨用分块循环约化法于下面方程的求解

22 不完全 LU 分解( ILU ) 参考 Yousef Saad 的书 《 Iterative methods for sparse linear systems 》的第 10 章. 该书第一版可以在 Saad 的主页上下载。

23 Cholesky factorization 1. Basic Cholesky factorization G. H. Golub, C. F. Van Loan, Matrix Computations, 3 rd ed., Johns Hopkins University Press, Baltimore and London, ) gaxpy Cholesky 2) outer-product Cholesky 3) 分块点积的 Cholesky 分解 4) 其他实现方法 比较各种方法的效率,并与 Matlab 函数 chol() 比较。

24 2. Incomplete Cholesky (IC) factorization T. A. Manteuffel, An incomplete factorization technique for positive definite linear systems, Mathematics of Computation, 34, 150(1980), J. Meijerink, H. A. Van der Vorst, An iterative solution method for linear systems of which the coefficient matrix is a symmetric M-matrix, Math. Comput., 31, 137(1977), pp R. S. Varga, E. B. Saff, V. Mehrmann, Incomplete factorizations of matrices and connections with H-matrices, SIAM J. Numer. Anal., 17(1980), pp 参考 G.H. Golub, C. F. Van Loan 的《 Matrix Computation 》. 中文版 p.620

25 I. E. Kaporin, High quality preconditioning of a general symmetric positive definite matrix based on its -docomposition, Numer. Linear Algebra Appl., 5(1998), pp Robust Incomplete Cholesky factorization 1) T. A. Manteuffel, An incomplete factorization technique for positive definite linear systems, Mathematics of Computation, 34, 150(1980), M. Ajiz, A. Jennings, A robust incomplete Choleski-conjugate gradient algorithm, Internat. J. Numer. Methods Engrg., 20, 5(1984), pp M. Tismenetsky, A new preconditioning technique for solving large sparse linear systems, Linear Algebra Appl., (1991), pp ) 3)

26 Let A be the matrix whose entries are zero everywhere except for the primes 2, 3, 5, 7, …, along the main diagonal and the number 1 in all the positions with. What is the (1,1) entry of ?

27 The Lorenz Strange Attractor The Lorenz system is given by Using the parameters and the initial conditions and (1)apply the Runge-Kutta method using step size to solve the system for and then plot each of the projection z vs. x, y vs. x, and y vs. z. (2)Perturb the initial conditions slightly to x(0)=-8.02, y(0)=7.98 (and same z(0)), solve the new system with the same method, and plot the original x minus the new x versus t on the whole time interval.

28 Numerical algorithms for solving the linear two-point boundary value problem (BVP) Two approach: 1)multiple shooting technique 2)finite-difference method( 建议用此法 ) S. J. Wright, Stable parallel algorithms for two-point boundary value problems, SIAM J. Sci. Stat. Comput., 13(1992), pp

29 在平面上把收敛到不同根的初始值分别标上不同颜色, 得到 Newton 法收敛域的彩色图片. 用 Newton 法解复数方程 Algorithms on 函数 fzero 的实现 QR 算法求特征值问题


Download ppt "Least Squares. 给定一组测量或观测值 假设 y 是 n 个函数的线性组合 设 m×n 矩阵 X 定义为 所以 β=X\y."

Similar presentations


Ads by Google