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 195055196 196066207 197082992 198098705 1990114333 2000 12674 3 s: -0.9667 -0.6333 -0.3000 0.0333 0.3667 0.7000 X: 0.9344 -0.9667 1.0000 0.4011 -0.6333 1.0000 0.0900 -0.3000 1.0000 0.0011 0.0333 1.0000 0.1344 0.3667 1.0000 0.4900 0.7000 1.0000 y: 55196 66207 82992 98705 114333 126743

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,(2010-1979)/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 = -1.1403 0.6945 -1.7987 0 -0.3122 0.4589 0 -0.2279 0.8786 0 0.0342 0.9985 0 0.4743 0.8186 0 1.0923 0.3390 y = 1.0e+005 * -1.4311 0.2787 0.7439 0.9860 1.0148 0.7991 X = -1.1403 0.6945 -1.7987 0 1.2525 0.3587 0 0 0.8640 0 0 1.0007 0 0 0.8490 0 0 0.4090 y = 1.0e+005 * -1.4311 0.9033 0.8349 0.9723 0.8255 0.3630 X = -1.1403 0.6945 -1.7987 0 1.2525 0.3587 0 0 -1.6236 0 0 0 y = 1.0e+005 * -1.4311 0.9033 -1.5667 0.0062 0.0058 -0.0318

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

16 X = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 秩亏损 (Rank Deficiency) 接近秩亏损 X\y ans = -7.5000 0 7.8333 pinv(X)*y ans = -7.5556 0.1111 7.7778 X\y-pinv(X)*y ans = 0.0556 -0.1111 0.0556 y = 16 17 18 19 20

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, 1996. 有中文版, 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. 627-656. 2. Block orthogonal factorization (BOF) G. Fairweather, I. Gladwell, Algorithms for almost block diagonal linear systems, SIAM Review, 46(2004), pp. 49-58. S. J. Wright, Stable parallel algorithms for two-point boundary value problem, SIAM J. Sci. Statist. Comput., 13(1992), pp. 742-764. 进一步探讨用分块循环约化法于下面方程的求解

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, 1996. 1) 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), 473-497. 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. 134-155. R. S. Varga, E. B. Saff, V. Mehrmann, Incomplete factorizations of matrices and connections with H-matrices, SIAM J. Numer. Anal., 17(1980), pp. 787-793. 参考 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. 483-509. 3. Robust Incomplete Cholesky factorization 1) T. A. Manteuffel, An incomplete factorization technique for positive definite linear systems, Mathematics of Computation, 34, 150(1980), 473- 497. M. Ajiz, A. Jennings, A robust incomplete Choleski-conjugate gradient algorithm, Internat. J. Numer. Methods Engrg., 20, 5(1984), pp. 949-966. M. Tismenetsky, A new preconditioning technique for solving large sparse linear systems, Linear Algebra Appl., 154-156(1991), pp. 331-353. 2) 3)

26 Let A be the matrix whose entries are zero everywhere except for the primes 2, 3, 5, 7, …, 224737 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. 742-764.

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


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

Similar presentations


Ads by Google