파일:Linear least squares2.svg

testwiki
둘러보기로 이동 검색으로 이동
    원본 파일 (SVG 파일, 실제 크기 154 × 179 픽셀, 파일 크기: 80 KB)

    이 파일은 위키미디어 공용에 있으며, 다른 프로젝트에서 사용하고 있을 가능성이 있습니다. 해당 파일에 대한 설명이 아래에 나와 있습니다.

    파일 설명

    설명
    English: Illustration of linear least squares.
    Français : Illustration de la méthode des moindres carrés avec une fonction linéaire.
    날짜
    출처 File:Linear least squares2.png
    저자 Krishnavedala
    SVG 발전
    InfoField
     이 SVG 파일의 소스 코드 문법이 올바릅니다.
     이 벡터 그림은 Matplotlib(으)로 제작되었습니다.
    소스 코드
    InfoField

    Python code

    Source code
    import matplotlib.pyplot as plt
    from matplotlib.patches import Circle
    import numpy as np
    from scipy.special import erfinv
    
    # Set up the grid and other parameters
    M, N = 50, 100
    A, B = -2.2, 7
    C, D = -4, 4
    a, b, c = 1., 3, 1
    p, q, r, s = 1, 7.5, 1.3, 0.16
    p = s*p
    q = s*q
    r = s*r
    
    X = np.linspace(A, B, N, dtype=np.float)
    XX = np.linspace(A, B, N+1, dtype=np.float)
    YY = p + q * XX + r * (XX**2)
    
    Xr = 7.0 * np.arange(N, dtype=np.float)
    Yr = Xr.copy()
    for i in range(N):
        rd = np.random.rand()
        Xr[i] = XX[i] * rd + XX[i+1] * (1 - rd)
        Yr[i] = p + q * XX[i] + r * (XX[i]**2) + 0.4 * erfinv(2*np.random.rand() - 1)
        
    # least squares fitting
    Mat = np.array([(0*Xr+1), Xr, Xr**2]).T
    V = np.matmul(Mat.T, Yr)
    V = np.linalg.solve(np.matmul(Mat.T, Mat), V)
    pe = V[0]; qe = V[1]; re = V[2];
    
    fig, ax = plt.subplots(1, 1, figsize=(2,2), edgecolor='k')
    
    ax.plot(X, pe + qe * X + re * (X**2), 'b', lw=2)
    myrad = 0.05
    for i in range(len(Xr)):
        sample = Circle((Xr[i], Yr[i]), myrad, color='r')
        ax.add_patch(sample)
    
    ax.grid(True)
    ax.set_xticks([-2, -1, 0, 1, 2])
    ax.set_yticks([-1, 0, 1, 2, 3])
    ax.axis('square')
    ax.axis([-2, 2, -1.7, 3.5])
    fig.savefig('least squares.svg', transparent=True, bbox_inches='tight')
    

    라이선스

    Creative Commons CC-Zero 이 파일은 크리에이티브 커먼즈 CC0 1.0 보편적 퍼블릭 도메인 귀속에 따라 이용할 수 있습니다.
    저작물에 본 권리증서를 첨부한 자는 법률에서 허용하는 범위 내에서 저작인접권 및 관련된 모든 권리들을 포함하여 저작권법에 따라 전 세계적으로 해당 저작물에 대해 자신이 갖는 일체의 권리를 포기함으로써 저작물을 퍼블릭 도메인으로 양도하였습니다. 저작권자의 허락을 구하지 않아도 이 저작물을 상업적인 목적을 포함하여 모든 목적으로 복제, 수정·변경, 배포, 공연·실연할 수 있습니다.

    설명

    이 파일이 나타내는 바에 대한 한 줄 설명을 추가합니다
    Illustration of linear least squares.

    이 파일에 묘사된 항목

    다음을 묘사함

    81,740 바이트

    image/svg+xml

    bc3edccd6af42637052ff552cae360324e4edbf1

    파일 역사

    날짜/시간 링크를 클릭하면 해당 시간의 파일을 볼 수 있습니다.

    날짜/시간섬네일크기사용자설명
    현재2018년 7월 13일 (금) 17:122018년 7월 13일 (금) 17:12 판의 섬네일154 × 179 (80 KB)wikimediacommons>KrishnavedalaUser created page with UploadWizard

    이 파일을 사용하는 문서가 없습니다.