zoukankan      html  css  js  c++  java
  • singular value decomposition

    http://web.stanford.edu/class/cs246/slides/dim-red.pdf

    http://web.mit.edu/be.400/www/SVD/Singular_Value_Decomposition.htm
    http://mathworld.wolfram.com/SingularValueDecomposition.html
    https://www.cs.cmu.edu/~venkatg/teaching/CStheory-infoage/book-chapter-4.pdf

    【close to a matrix of low rank 用低秩矩阵逼近  svd是得到低秩矩阵的计算方法之一】

    First, in many applications, the data matrix A is close to a
    matrix of low rank and it is useful to find a low rank matrix which is a good approximation
    to the data matrix .

    【从一维直线切入】

    To gain insight into the SVD, treat the rows of an n × d matrix A as n points in a
    d-dimensional space and consider the problem of finding the best k-dimensional subspace
    with respect to the set of points. Here best means minimize the sum of the squares of the
    perpendicular distances of the points to the subspace. We begin with a special case of
    the problem where the subspace is 1-dimensional, a line through the origin. We will see
    later that the best-fitting k-dimensional subspace can be found by k applications of the
    best fitting line algorithm. Finding the best fitting line through the origin with respect
    to a set of points {xi|1 ≤ i ≤ n} in the plane means minimizing the sum of the squared
    distances of the points to the line. Here distance is measured perpendicular to the line.
    The problem is called the best least squares fit.

    Singular matrix

    C:Python36python.exe "C:Program Files (x86)JetBrainsPyCharm 2017.1helperspydevpydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 63304 --file D:/pymine/clean/filter_mac/1.py
    pydev debugger: process 49536 is connecting
    
    Connected to pydev debugger (build 171.3780.115)
    Traceback (most recent call last):
      File "C:Program Files (x86)JetBrainsPyCharm 2017.1helperspydevpydevd.py", line 1578, in <module>
        globals = debugger.run(setup['file'], None, None, is_module)
      File "C:Program Files (x86)JetBrainsPyCharm 2017.1helperspydevpydevd.py", line 1015, in run
        pydev_imports.execfile(file, globals, locals)  # execute the script
      File "C:Program Files (x86)JetBrainsPyCharm 2017.1helperspydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
        exec(compile(contents+"
    ", file, 'exec'), glob, loc)
      File "D:/pymine/clean/filter_mac/1.py", line 16, in <module>
        x = np.linalg.solve(a, b)
      File "C:Python36libsite-packages
    umpylinalglinalg.py", line 375, in solve
        r = gufunc(a, b, signature=signature, extobj=extobj)
      File "C:Python36libsite-packages
    umpylinalglinalg.py", line 90, in _raise_linalgerror_singular
        raise LinAlgError("Singular matrix")
    numpy.linalg.linalg.LinAlgError: Singular matrix
    
    import numpy as np
    
    a, b = np.matrix('1 1;1 1'), np.matrix('1;1')
    c = a * b
    
    a, b = np.array([[3, 1], [1, 2]]), np.array([9, 8])
    x = np.linalg.solve(a, b)
    
    a, b = np.array([[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, -1]]), np.array([8, 13, 8, 6])
    x = np.linalg.solve(a, b)
    
    a, b = np.array([[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, -1]]), np.array([8, 13, 8, 6])
    x = np.linalg.solve(a, b)
    
    a, b = np.array([[1, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, -1]]), np.array([8, 13, 8, 6])
    x = np.linalg.solve(a, b)
    
    import numpy as np
    
    a, b = np.matrix('1 1;1 1'), np.matrix('1;1')
    c = a * b
    
    a, b = np.array([[3, 1], [1, 2]]), np.array([9, 8])
    x = np.linalg.solve(a, b)
    
    a, b = np.array([[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, -1]]), np.array([8, 13, 8, 6])
    x = np.linalg.solve(a, b)
    
    a, b = np.array([[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, -1]]), np.array([8, 13, 8, 6])
    x = np.linalg.solve(a, b)
    
    a, b = np.array([[1, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, -1]]), np.array([8, 13, 8, 6])
    x = np.linalg.solve(a, b)
    
    
    a, b = np.array([[1, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]), np.array([8, 13, 8, 6])
    x = np.linalg.solve(a, b)
    
    
    s = 9
    C:Python36python.exe "C:Program Files (x86)JetBrainsPyCharm 2017.1helperspydevpydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 64411 --file D:/pymine/clean/filter_mac/1.py
    pydev debugger: process 27204 is connecting
    
    Connected to pydev debugger (build 171.3780.115)
    Traceback (most recent call last):
      File "C:Program Files (x86)JetBrainsPyCharm 2017.1helperspydevpydevd.py", line 1578, in <module>
        globals = debugger.run(setup['file'], None, None, is_module)
      File "C:Program Files (x86)JetBrainsPyCharm 2017.1helperspydevpydevd.py", line 1015, in run
        pydev_imports.execfile(file, globals, locals)  # execute the script
      File "C:Program Files (x86)JetBrainsPyCharm 2017.1helperspydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
        exec(compile(contents+"
    ", file, 'exec'), glob, loc)
      File "D:/pymine/clean/filter_mac/1.py", line 16, in <module>
        x = np.linalg.solve(a, b)
      File "C:Python36libsite-packages
    umpylinalglinalg.py", line 375, in solve
        r = gufunc(a, b, signature=signature, extobj=extobj)
      File "C:Python36libsite-packages
    umpylinalglinalg.py", line 90, in _raise_linalgerror_singular
        raise LinAlgError("Singular matrix")
    numpy.linalg.linalg.LinAlgError: Singular matrix

    http://mathworld.wolfram.com/SingularMatrix.html

    square matrix that does not have a matrix inverse. A matrix is singular iff its determinant is 0.

    【当且仅当 -- 方阵且行列式为0】奇异矩阵首先是方阵,其次是行列式值为0;;; 

    http://mathworld.wolfram.com/Determinant.html

  • 相关阅读:
    python中创建列表、元组、字符串、字典、集合
    python中字典的键不允许重复
    python中生成字典
    python中实现列表元素的倒序排列
    python中实现字典的逆向排列
    python中增加字典的键值对(项)、修改键值对的值
    python中访问字典
    Fortran 2003:完美还是虚幻?(节选)
    感谢裘宗燕老师!
    “符号化”的效用和缺失
  • 原文地址:https://www.cnblogs.com/rsapaper/p/7532553.html
Copyright © 2011-2022 走看看