부분공간·직교투영·최소제곱Subspaces, orthogonal projections and least squares
공간의 정의에서 실제 펭귄 적합·직교잔차·계수 유일성까지From subspaces to actual penguin fits, orthogonal residuals and coefficient uniqueness
실습 6종 · 풀이 포함 연습문제 35개6 labs · 35 exercises with solutions
기초Foundations
1. 모든 점을 지나는 답이 없을 때1. When no answer passes through every observation
친구 다섯 명의 공부 시간과 시험점수를 점으로 찍었다고 합시다. 모든 점을 정확히 지나는 직선은 없을 수 있습니다. 그렇다고 아무 직선이나 골라도 되는 것은 아닙니다. 무엇을 작게 만들 것인지 먼저 정하고, 그 기준에서 가장 가까운 답을 찾아야 합니다.
이 장은 13장의 한 방향 정사영과 14장의 행렬을 연결합니다. 여러 방향이 만드는 부분공간에 관측벡터를 가장 가깝게 옮기는 문제를 풀겠습니다. 앞의 친구 예는 설명용 상황이며, 실제 수치 실습은 공개 펭귄 관측과 별도로 표시한 가정 자료를 사용합니다.
A straight line may fail to pass through every study-time and score observation. Choosing any line is not enough: first state the discrepancy to minimize, then find the closest answer under that criterion.
This chapter joins one-direction projection from Chapter 13 with matrices from Chapter 14. We project an observation vector onto a subspace generated by several directions. The introductory situation is illustrative; actual penguin records and hypothetical numerical examples are labeled separately.
기초Foundations
2. 부분공간: 0·합·상수배를 지키는 모임2. Subspaces preserve zero, addition and scalar multiplication
평면에서 원점을 지나는 직선은 벡터를 더하거나 실수배해도 그 직선에 남습니다. 이처럼 0벡터를 포함하고 합과 모든 실수배에 닫힌 집합을 부분공간이라 부릅니다. 단지 그림이 평평해 보인다는 뜻이 아닙니다.
0∈W,u,v∈W⟹αu+βv∈W(α,β∈R)
y=2x는 부분공간이지만 y=2x+1은 원점을 포함하지 않아 아닙니다. 첫 사분면은 0을 포함하도록 잡더라도 음수배에서 벗어나므로 아닙니다. 반지름 1인 원은 0을 포함하지 않고, 두 점을 더해도 원에 남지 않을 수 있습니다.
0만 있는 집합과 전체 공간도 부분공간입니다. 이후의 정사영 정리는 아무 곡선이나 임의 집합에 그대로 적용하지 않습니다. 어떤 대상에 대해 정리가 성립하는지 정의부터 확인하는 습관이 필요합니다.
A line through the origin keeps vector sums and real scalar multiples on the same line. A subspace contains zero and is closed under these operations; it is not merely a flat-looking shape.
0∈W,u,v∈W⟹αu+βv∈W(α,β∈R)
The line y=2x qualifies, but y=2x+1 does not contain zero. A nonnegative quadrant fails negative scaling, and a unit circle fails the required conditions.
The zero-only set and the entire ambient space also qualify. Projection results below concern subspaces, not arbitrary curves or sets without checking their conditions.
기초Foundations
3. 생성공간: 몇 방향으로 갈 수 있는 모든 곳3. A span contains every combination of given directions
u,v를 얼마나씩 써도 좋다고 하면 au+bv로 갈 수 있는 모든 점이 생깁니다. 이 모임을 span(u,v), 생성공간이라고 씁니다. 계수를 모두 0으로 놓으면 0이 있고, 두 조합을 더하거나 배수해도 다시 같은 조합 꼴이므로 부분공간입니다.
span(u,v)={au+bv:a,b∈R}
평면에서 둘 다 0이면 생성공간은 0 하나입니다. 비영벡터가 한 방향뿐이면 직선이고, 서로 배수가 아닌 두 방향이면 평면 전체입니다. 화면의 유한한 격자나 계수 슬라이더 범위는 관찰 창이지 생성공간 전체를 유한하게 제한한다는 뜻이 아닙니다.
실습에서 두 방향을 겹치게 했다가 벌려 보세요. 벡터의 개수보다 독립적인 방향의 수가 중요합니다. 같은 방향을 두 번 추가해도 갈 수 있는 범위는 넓어지지 않습니다.
Allow arbitrary real coefficients in au+bv. Their possible results form span(u,v). Zero coefficients give zero; sums and multiples remain combinations, so every span is a subspace.
span(u,v)={au+bv:a,b∈R}
In the plane, two zero generators give only zero; one nonzero direction gives a line; two independent directions give the whole plane. A finite plotting window or slider range is only an observation window, not the mathematical span.
Move the directions into and out of alignment. Independent directions, rather than the number listed, determine the reach of their combinations.
기초Foundations
4. 기저와 차원: 중복 없이 공간을 설명하기4. Bases and dimension remove redundant directions
공간 전체를 생성하면서 어느 벡터도 나머지의 조합으로 대신할 수 없는 목록이 기저입니다. 정확히는 생성성과 선형독립성을 함께 요구합니다. 독립이라는 말은 확률적 독립이 아니라 c₁v₁+⋯+cₖvₖ=0의 계수가 모두 0이어야 한다는 대수적 조건입니다.
c1v1+⋯+ckvk=0⟹c1=⋯=ck=0
평면의 (1,0),(0,1)도, (1,1),(1,−1)도 기저입니다. 기저가 유일하지 않아도 기저에 들어가는 독립적인 벡터의 수는 같습니다. 그 수를 차원이라고 합니다. 같은 공간이라면 기저 좌표는 달라도 원래 벡터와 투영 결과는 달라지지 않습니다.
0공간은 차원이 0이고 빈 목록을 기저로 봅니다. 임의로 0벡터를 기저 원소라고 넣으면 독립성이 깨집니다. 모든 표현을 눈으로 그릴 필요는 없지만 정의에서 0의 예외를 빼먹지 않아야 합니다.
A basis spans the space without redundant directions. It must both span and be linearly independent: a zero combination forces every coefficient to zero. This is algebraic, not probabilistic, independence.
c1v1+⋯+ckvk=0⟹c1=⋯=ck=0
Both standard directions and (1,1),(1,−1) form planar bases. Bases vary, but their size, the dimension, does not. Coordinates can change while the represented vector and projection remain the same.
The zero space has dimension zero with an empty basis. Adding a zero vector to a basis would violate independence.
기초Foundations
5. 열공간은 가능한 출력, 영공간은 지워지는 입력5. Column spaces contain outputs; null spaces contain lost inputs
m×p 행렬 X의 열들은 길이 m인 벡터입니다. 그 조합 Xβ로 만들 수 있는 모든 출력을 열공간 Col(X)라고 부릅니다. 반면 Xz=0인 입력 z의 모임은 ℝᵖ의 영공간입니다. 두 공간은 보통 놓여 있는 차원부터 다릅니다.
Col(X)⊆Rm,Null(X)⊆Rp
직선을 적합할 때 행이 다섯 관측, 열이 상수 1과 입력 x라면 X는 5×2입니다. 적합값 벡터는 ℝ⁵의 열공간 안에 있고, 계수 β는 ℝ²에 있습니다. 화면의 시간–점수 산점도 ℝ²와 다섯 관측의 출력공간 ℝ⁵는 서로 다른 그림입니다.
이 구별이 어렵다면 ‘두 계수로 다섯 예측값을 만든다’고 읽어 보세요. 계수공간의 점과 관측공간의 점을 같은 화살표라고 섞지 않는 것이 투영과 회귀를 연결하는 첫 단계입니다.
The columns of an m×p matrix X lie in ℝᵐ. Their combinations Xβ form Col(X). Inputs z with Xz=0 form Null(X) inside ℝᵖ. These spaces generally have different ambient dimensions.
Col(X)⊆Rm,Null(X)⊆Rp
For five observations and two columns, constant one and input x, the design is 5×2. Fitted values live in ℝ⁵, while coefficients live in ℝ². A two-axis scatterplot is not the same geometry as the five-component observation space.
Read this as “two coefficients produce five predictions.” Keep coefficient and observation vectors distinct when connecting projection to regression.
기초Foundations
6. 직교여공간: 모든 방향과 직교하기6. Orthogonal complements require every direction
부분공간 W의 모든 벡터와 내적이 0인 벡터들의 모임을 W⊥라고 씁니다. W 안의 단 한 벡터와 직교하는 것만으로는 충분하지 않습니다. 다만 W의 기저와 각각 직교하면 그 선형결합과도 직교하므로 전체를 확인한 셈입니다.
W⊥={r:r⋅w=0for every w∈W},Col(X)⊥=Null(XT)
마지막 등식은 Xᵀr의 각 성분이 X의 한 열과 r의 내적이라는 사실에서 나옵니다. 모든 성분이 0이면 모든 열 및 그 조합과 직교합니다. 나중의 정규방정식은 바로 이 식을 관측잔차에 적용한 것입니다.
ℝ³의 xy평면과 직교하는 벡터는 z축의 벡터입니다. W와 W⊥에 동시에 속하면 자기 자신과도 직교해야 하므로 길이 제곱이 0, 즉 0벡터입니다. 이 성질이 뒤의 분해의 유일성을 만듭니다.
W⊥ contains vectors orthogonal to every vector in W. Checking only one arbitrary member is insufficient; checking a basis suffices by linearity.
W⊥={r:r⋅w=0for every w∈W},Col(X)⊥=Null(XT)
Each entry of Xᵀr is the dot product of a column with r. Vanishing entries mean orthogonality to all columns and hence their span. This will become the normal-equation condition on residuals.
The complement of the xy-plane in ℝ³ is the z-axis. A vector in both W and W⊥ has zero self-product, so their intersection contains only zero.
기초Foundations
7. 관측을 투영과 직교잔차로 나누기7. Decompose a vector into projection and orthogonal residual
u=(2,−1,3)을 xy평면에 옮길 때 가장 가까운 점은 p=(2,−1,0)입니다. 남은 r=(0,0,3)은 평면의 모든 방향과 직교합니다. u=p+r로 원래 벡터를 두 역할로 나눴습니다.
u=p+r,p∈W,r∈W⊥,∥u∥2=∥p∥2+∥r∥2
예제의 제곱길이는 14=5+9입니다. 실습의 좌표별 막대와 표는 세 성분을 읽기 위한 표현입니다. 2차원 화면에 그린 임의의 두 막대가 원래 3차원 벡터의 각도를 그대로 보여 준다고 해석하지 않습니다.
일반적인 유한차원 부분공간에도 이런 분해가 존재하며 유일합니다. 존재는 직교기저를 만들어 투영을 합하는 9~12절에서 확인합니다. 유일성은 두 분해를 뺀 차이가 W와 W⊥에 동시에 속하므로 0이라는 사실로 증명됩니다.
Project u=(2,−1,3) onto the xy-plane. The point p=(2,−1,0) leaves residual r=(0,0,3), orthogonal to every planar direction.
u=p+r,p∈W,r∈W⊥,∥u∥2=∥p∥2+∥r∥2
Squared lengths give 14=5+9. Coordinate bars and tables report three components; arbitrary two-dimensional display angles are not the original three-dimensional angles.
Every finite-dimensional subspace admits this unique decomposition. Sections 9–12 construct it with an orthogonal basis. Subtracting two decompositions proves uniqueness because the difference belongs to both W and W⊥.
기초Foundations
8. 왜 그 점이 가장 가까운가8. Why this point is closest
투영 p가 공간 안에 있고 r=u−p가 공간 전체와 직교한다고 합시다. 다른 후보 w∈W를 잡으면 p−w도 W 안에 있습니다. 따라서 r과 p−w는 직교합니다.
∥u−w∥2=∥r+(p−w)∥2=∥r∥2+∥p−w∥2≥∥r∥2
오른쪽의 두 번째 제곱길이는 음수가 아니고 w=p일 때만 0입니다. 그래서 p가 유일하게 가장 가까운 점입니다. 이 증명은 좌표를 미분하지 않고도 모든 방향을 한 번에 비교합니다.
‘최선’이라는 말에는 기준이 붙습니다. 여기서는 같은 단위와 가중치를 가진 유클리드 제곱거리를 작게 만든 것입니다. 절대오차 합이나 다른 가중치를 쓰면 다른 답이 나올 수 있습니다. 수학적 최선이 현실의 모든 목적에서 최선이라는 뜻은 아닙니다.
Suppose p∈W and r=u−p is orthogonal to W. For another candidate w∈W, the difference p−w remains in W and is orthogonal to r.
∥u−w∥2=∥r+(p−w)∥2=∥r∥2+∥p−w∥2≥∥r∥2
The second term is nonnegative and vanishes only at w=p, proving unique closest-point optimality without differentiating coordinates.
“Best” refers to this Euclidean squared-distance criterion. Absolute deviations or different weights may yield another answer. Mathematical optimality under one criterion is not universal practical superiority.
기초Foundations
9. 직교기저와 정규직교기저9. Orthogonal and orthonormal bases
서로 다른 벡터끼리 내적이 0이고 각 벡터가 0이 아니면 직교 목록입니다. 각 길이까지 1이면 정규직교 목록입니다. 0벡터를 허용하면 독립성이나 나누기 조건이 무너지므로 여기서는 목록의 원소에서 제외합니다.
qi⋅qj={10i=ji=j,QTQ=Ik
직교하는 비영벡터들은 독립입니다. Σcⱼvⱼ=0에 vᵢ를 내적하면 다른 항은 사라지고 cᵢ‖vᵢ‖²=0이므로 cᵢ=0입니다. 따라서 공간을 생성하는 직교 목록은 기저가 됩니다.
Q의 열이 정규직교이면 QᵀQ=Iₖ입니다. 그러나 Q가 m×k이고 k<m이면 QQᵀ까지 Iₘ인 것은 아닙니다. 원래 관측공간 전체가 아니라 k차원 부분공간만 다루는 차이를 기억하세요.
An orthogonal list has mutually orthogonal nonzero members. If every length is one, it is orthonormal. Excluding zero prevents failures of independence and division.
qi⋅qj={10i=ji=j,QTQ=Ik
Dotting a zero linear combination with vᵢ leaves cᵢ‖vᵢ‖²=0, hence cᵢ=0. Orthogonal nonzero vectors are therefore independent; an orthogonal spanning list is a basis.
For orthonormal columns, QᵀQ=Iₖ. But if Q is m×k with k<m, QQᵀ need not be Iₘ. A lower-dimensional subspace differs from the full observation space.
기초Foundations
10. 직교기저에서는 투영을 더할 수 있다10. Add direction projections when the basis is orthogonal
v₁,…,vₖ가 W의 직교기저라면 각 방향의 정사영을 더합니다. p는 W 안의 조합이고, 잔차에 vᵢ를 내적하면 해당 항만 남아 정확히 소거됩니다. 그러므로 앞의 가장 가까운 점 조건이 성립합니다.
p=j=1∑kvj⋅vju⋅vjvj,p=QQTufor orthonormal columns of Q
정규직교라면 분모가 1입니다. u의 기저좌표를 Qᵀu로 읽고 Q를 다시 곱해 원래 관측공간으로 되돌립니다. k=0인 0공간에서는 빈 합을 0으로 두어 모든 u의 투영이 0입니다.
기저를 다른 정규직교기저로 바꾸어도 가장 가까운 점의 유일성 때문에 p는 같습니다. 중간 좌표의 이름과 값이 바뀌는 것과 최종 벡터가 바뀌는 것을 구별하세요.
For an orthogonal basis, sum the one-direction projections. The result lies in W, and each residual dot product cancels, establishing the closest-point condition.
p=j=1∑kvj⋅vju⋅vjvj,p=QQTufor orthonormal columns of Q
Orthonormality makes denominators one. Qᵀu gives basis coordinates and Q maps them back. For the zero space, an empty sum is zero.
Changing the orthonormal basis changes coordinates but not the unique projected vector. Distinguish internal representations from the final point.
기초Foundations
11. 비직교 방향에 같은 공식을 쓰면 생기는 오류11. The formula fails for a nonorthogonal basis
v₁=(1,0), v₂=(1,1)은 평면 전체의 기저지만 직교하지 않습니다. u=(0,1)은 이미 평면 안에 있으므로 올바른 투영은 u 자체입니다. 그런데 각 직선 투영을 그대로 더하면 어떻게 될까요?
projv1u+projv2u=0+21(1,1)=(21,21)=(0,1)
남은 잔차 (−1/2,1/2)는 v₁과 내적이 −1/2라 전체 공간과 직교하지 않습니다. 겹치는 방향을 서로 독립적인 직각 성분처럼 더했기 때문입니다. 기저라는 조건만으로 10절의 단순 합을 사용할 수 없습니다.
해결 방법은 직교기저를 만들거나, 여러 방향을 함께 고려하는 정규방정식을 푸는 것입니다. 어느 길도 원래 두 방향이 직교한다고 가정할 필요는 없습니다.
The vectors (1,0),(1,1) form a nonorthogonal planar basis. Since u=(0,1) already lies in the plane, its true projection is itself. Summing independent line projections instead gives the wrong result.
projv1u+projv2u=0+21(1,1)=(21,21)=(0,1)
The resulting residual has dot product −1/2 with v₁, so it is not orthogonal to the span. A basis alone does not justify the simple sum; orthogonality matters.
Construct an orthogonal basis or solve the joint normal equations. Neither route assumes the original directions were orthogonal.
기초Foundations
12. Gram–Schmidt: 이미 있는 방향을 빼고 정규화하기12. Gram–Schmidt subtracts existing directions before normalization
첫 비영벡터 v₁을 길이로 나누어 q₁을 만듭니다. 둘째 v₂에서는 q₁ 방향의 성분을 빼고 남은 z₂를 정규화합니다. 서로 다른 방향의 정보만 남기기 위한 순서입니다.
v₁=(1,1), v₂=(1,0)이면 q₁=(1,1)/√2, 뺄 투영은 (1/2,1/2), 남은 z₂=(1/2,−1/2)입니다. 그 길이는 1/√2라 q₂=(1,−1)/√2입니다. 내적 0, 각 길이 1을 직접 확인하세요.
첫 입력이 0이면 첫 정규화가 불가능합니다. 둘째가 첫째의 배수이면 z₂=0이므로 새 기저방향을 만들 수 없습니다. 일반 알고리즘은 종속 벡터를 건너뛸 수 있지만, 이 두 방향 실습은 이유를 표시하고 두 번째 단위벡터를 강제로 만들지 않습니다. 거의 종속일 때의 수치적 주의는 12·17장과 연결합니다.
Normalize a nonzero first vector. Subtract its component from the second vector, then normalize the remainder. This retains new directional information.
For (1,1),(1,0), obtain q₁=(1,1)/√2, remainder (1/2,−1/2) and q₂=(1,−1)/√2. Verify unit lengths and a zero dot product.
A zero first input cannot be normalized. A dependent second input leaves zero remainder and no new direction. A general algorithm can skip dependent members; this two-direction lab reports the reason instead of inventing a second unit vector. Near-dependence also raises numerical issues.
선택 심화Optional extension
13. 선택 연결: 직교기저를 QR로 기록하기13. Optional bridge: record the orthogonal basis as QR
X의 독립적인 열을 순서대로 Gram–Schmidt 처리하면 정규직교 열을 가진 Q와 위삼각행렬 R을 얻습니다. 각 원래 열이 앞에서 만든 q들의 조합이라는 계수를 R에 적은 것입니다. X=QR이며 Q는 원래 열공간의 기저를 담습니다.
X=QR,QTQ=Ip,β=R−1QTyif X has full column rank
마지막 식은 실제 계산에서 R⁻¹을 전부 만들라는 지시가 아닙니다. 위삼각 연립방정식 Rβ=Qᵀy를 역대입으로 풉니다. 행렬의 분해와 방정식을 푸는 절차를 구별하세요.
고전적인 Gram–Schmidt는 거의 종속인 입력에서 직교성을 잃을 수 있습니다. 실무 라이브러리는 Householder QR나 SVD 같은 더 안정적인 방법을 사용합니다. 여기의 정확한 산술 유도는 구조를 이해하는 목적이며 모든 수치상황에 최선의 구현이라는 주장이 아닙니다.
Applying Gram–Schmidt to independent columns yields X=QR, with orthonormal columns in Q and an upper triangular R recording how original columns combine those directions.
X=QR,QTQ=Ip,β=R−1QTyif X has full column rank
The displayed inverse is a conceptual expression, not an instruction to construct it explicitly. Solve Rβ=Qᵀy by back substitution.
Classical Gram–Schmidt can lose orthogonality for nearly dependent data. Practical libraries use stable QR or SVD methods. Exact-arithmetic derivations explain structure rather than certify every numerical implementation.
기초Foundations
14. 최소제곱: 무엇을 작게 만드는지 먼저 정하기14. Least squares first specifies what to minimize
관측 y와 적합값 Xβ의 차이를 잔차 e=y−Xβ라고 부릅니다. 최소제곱은 각 잔차를 제곱해 더한 SSE를 가장 작게 만드는 β를 찾습니다. 제곱하면 양수·음수가 소거되지 않고 큰 오차에 더 큰 벌점이 생깁니다.
SSE(β)=∥y−Xβ∥22=i=1∑m(yi−xiTβ)2
제곱오차를 선택했다고 모든 관측오차가 정규분포라고 가정한 것은 아닙니다. 지금은 고정된 수치문제입니다. 확률적 가정은 추정의 불확실성을 말할 때 추가합니다. 잔차는 관측과 선택 모형의 차이이지 반드시 측정 실수라고만 부를 수 없습니다.
y가 열공간 안에 있으면 SSE=0인 정확한 해가 있습니다. 밖에 있어도 유한차원 열공간에 가장 가까운 적합벡터가 존재합니다. 그 벡터는 유일하지만 이를 만드는 계수는 아직 유일하다고 말하지 않았습니다.
Residuals are e=y−Xβ. Least squares selects coefficients minimizing their squared sum, SSE. Squaring prevents signed cancellation and penalizes large discrepancies more heavily.
SSE(β)=∥y−Xβ∥22=i=1∑m(yi−xiTβ)2
A squared-loss calculation does not itself assume normally distributed errors. This is a fixed numerical problem; probabilistic assumptions are additional. Residuals describe discrepancies from a chosen model, not necessarily measurement mistakes.
If y lies in the column space, an exact fit gives zero SSE. Otherwise its unique closest fitted vector still exists. Whether its coefficient representation is unique is a separate question.
기초Foundations
15. 정규방정식: 잔차가 모든 열과 직교해야 한다15. Normal equations make residuals orthogonal to every column
최적 적합값 ŷ=Xβ̂의 잔차가 열공간과 직교해야 하므로 Xᵀ(y−Xβ̂)=0입니다. 이를 정리한 것이 정규방정식입니다. 여기의 ‘정규’는 정규분포 가정을 뜻하지 않습니다.
XTXβ=XTy,XTe=0
충분성은 피타고라스로 검산됩니다. 다른 계수 β̂+d에 대한 잔차는 e−Xd이고, e·Xd=0이므로 SSE(β̂+d)=‖e‖²+‖Xd‖²입니다. 따라서 더 작아질 수 없습니다.
필요성도 한 방향씩 확인할 수 있습니다. 어떤 열 a와 e의 내적이 0이 아니면 적합값을 ta만큼 바꾼 SSE는 ‖e‖²−2t(e·a)+t²‖a‖²입니다. 알맞은 부호의 충분히 작은 t를 택하면 감소하므로 최적일 수 없습니다. 이 유도에는 아직 확률모형이나 다변수 미분이 필요하지 않습니다.
An optimal residual is orthogonal to Col(X), giving Xᵀ(y−Xβ̂)=0, the normal equations. “Normal” here refers to orthogonality, not a normal probability distribution.
XTXβ=XTy,XTe=0
For any coefficient change d, orthogonality yields SSE(β̂+d)=‖e‖²+‖Xd‖², proving sufficiency.
For necessity, a nonzero e·a for some column a makes ‖e−ta‖²=‖e‖²−2t(e·a)+t²‖a‖² decrease for a suitable sufficiently small t. Thus every column dot product must vanish. No probability model or multivariable calculus is required.
기초Foundations
16. 가정한 다섯 점으로 끝까지 계산하기16. Work through five hypothetical points
설명용으로 x=(−2,−1,0,1,2), y=(−1,0,2,2,4)를 정합니다. 실제 조사자료가 아닙니다. 모형은 ŷᵢ=a+bxᵢ이고 X의 두 열은 1과 x입니다. Σxᵢ=0이어서 두 열이 직교합니다.
XTX=(50010),XTy=(712),a=57,b=56
적합값은 (−1,0.2,1.4,2.6,3.8), 잔차는 (0,−0.2,0.6,−0.6,0.2)입니다. 잔차합과 x를 곱한 잔차합이 모두 0이고, 제곱합은 0.8입니다. 표의 각 행에서 관측−적합=잔차인지 확인하세요.
실습에서 a,b를 바꾸면 현재 SSE와 최적값을 비교할 수 있습니다. 산점도에서 보이는 세로 오차를 제곱한 합을 최소화하며, 점에서 직선까지의 가장 짧은 수직거리를 최소화하는 별도 문제와 구별합니다. 변수 단위를 바꾸면 목적함수의 의미도 점검해야 합니다.
Use hypothetical x=(−2,−1,0,1,2), y=(−1,0,2,2,4), not survey observations. Fit ŷᵢ=a+bxᵢ using columns one and x. Their dot product vanishes because the x values sum to zero.
XTX=(50010),XTy=(712),a=57,b=56
Fitted values are (−1,0.2,1.4,2.6,3.8); residuals are (0,−0.2,0.6,−0.6,0.2). Both the residual sum and x-weighted residual sum are zero, and SSE is 0.8.
Change a and b to compare current and optimal loss. This minimizes squared vertical y-errors, not the separate problem of shortest perpendicular distances from scatterplot points to a line.
기초Foundations
17. 절편과 기울기 공식을 평균에서 유도하기17. Derive intercept and slope from centered observations
절편을 포함한 정규방정식의 첫 식은 Σ(yᵢ−a−bxᵢ)=0입니다. m으로 나누면 a=ȳ−b x̄입니다. 이를 두 번째 식에 넣어 중심화하면 아래 공식을 얻습니다. 분모가 양수이려면 x가 모두 같지 않아야 합니다.
왜 평균을 빼도 될까요? 중심화한 값의 합은 0이므로 상수항이 내적에서 사라집니다. 이는 평균과 편차 방향으로 관측을 나누는 기하입니다. 분모가 0이면 기울기를 0으로 나누어 계산하지 말고 랭크결손 문제로 처리합니다.
해석하기 편한 기준 x₀를 골라 ŷ=c+b(x−x₀)로 써도 같은 직선입니다. c=a+bx₀이고 a=c−bx₀입니다. x₀=x̄이면 두 설계열이 직교하지만, 단지 x₀를 200처럼 가까운 숫자로 정했다는 이유만으로 정확한 직교성이 생기는 것은 아닙니다.
The intercept normal equation gives Σ(yᵢ−a−bxᵢ)=0, hence a=ȳ−b x̄. Substitution into the other equation yields the centered slope formula, provided x is not constant.
Centered values sum to zero, eliminating constant terms from the relevant inner products. A zero denominator indicates rank deficiency, not permission to divide by zero.
Writing ŷ=c+b(x−x₀) gives the same line, with c=a+bx₀. The design columns are orthogonal when x₀=x̄. A convenient nearby reference such as 200 does not by itself produce exact orthogonality.
기초Foundations
18. 적합값은 유일해도 계수는 여러 개일 수 있다18. Fitted values can be unique while coefficients are not
열공간으로의 투영 ŷ는 유일한 가장 가까운 점입니다. 그러나 같은 점을 만드는 열의 조합은 여러 개일 수 있습니다. X의 열이 독립이면 Xβ₁=Xβ₂에서 β₁=β₂지만, 영공간이 있으면 그 방향을 더해도 적합값은 같습니다.
XTX invertible⟺rank(X)=p,β=(XTX)−1XTyonly under full column rank
조건의 이유는 zᵀXᵀXz=‖Xz‖²입니다. 열이 독립이면 z≠0에서 이 값이 양수여서 XᵀX는 가역입니다. 종속이면 0이 아닌 z가 Xz=0을 만족하므로 XᵀX도 그 방향을 지워 역행렬이 없습니다.
따라서 정규방정식은 랭크결손에서도 사용할 수 있지만 ‘역행렬을 취한 공식’은 사용할 수 없습니다. 하나의 계수를 고르는 추가 규칙은 별도입니다. 17장의 SVD와 의사역행렬은 그런 선택을 정리하되, 잃어버린 관측 정보를 새로 만드는 것은 아닙니다.
The closest fitted vector is unique. Its representation through columns may not be. Independent columns give unique coefficients; a nontrivial null space permits coefficient changes that leave the fit unchanged.
XTX invertible⟺rank(X)=p,β=(XTX)−1XTyonly under full column rank
The key identity is zᵀXᵀXz=‖Xz‖². Independent columns make it positive for nonzero z. A nonzero null vector makes XᵀX singular.
Normal equations remain valid when rank is deficient; the inverse formula does not. Choosing one representative requires an additional rule. SVD and pseudoinverses in Chapter 17 organize such choices without creating missing observational information.
기초Foundations
19. 중복 열을 넣어 비유일성을 직접 보기19. Observe nonuniqueness with a duplicate direction
16절의 다섯 점에서 X의 열을 1,x,2x로 바꿔 봅시다. 셋째 열은 새 방향이 아닙니다. 계수 (a,b,d)가 만드는 직선은 a+(b+2d)x이므로 b와 d를 따로 바꾸어도 합성 기울기만 같으면 모든 적합값이 같습니다.
β(t)=1.41.2−2tt,Xβ(t)=1.41+1.2x,X0−21=0
모든 실수 t에서 SSE는 0.8입니다. t=0의 (1.4,1.2,0)과 t=1의 (1.4,−0.8,1)은 계수가 다르지만 같은 예측벡터를 만듭니다. 슬라이더에서 움직이는 것은 현실의 효과가 아니라 같은 적합을 표현하는 자유도입니다.
열이 3개라는 이유로 세 가지 독립 효과를 추정했다고 말할 수 없습니다. 정규화나 제약으로 한 답을 고를 수는 있지만 그 선택이 어떤 가정을 더했는지 공개해야 합니다. 통계·계량경제학에서 다중공선성으로 다시 연결합니다.
Replace the toy design by columns one, x and 2x. Its prediction is a+(b+2d)x, so varying b and d while preserving their combined slope leaves all predictions unchanged.
β(t)=1.41.2−2tt,Xβ(t)=1.41+1.2x,X0−21=0
Every real t gives SSE 0.8. The coefficients differ, while the fitted vector does not. The slider moves a representation's free direction, not a real-world causal effect.
Three listed columns do not establish three separately identified effects. Constraints or regularization can select a representative, but the extra assumption must be stated.
정규직교기저 Q에서 P=QQᵀ로 두면 ŷ=Py입니다. 다시 적용해도 P²=Q(QᵀQ)Qᵀ=P입니다. 투영된 점은 이미 공간 안에 있기 때문입니다. 이를 멱등성이라고 부릅니다.
P=QQT,PT=P,P2=P,P=X(XTX)−1XTif X has full column rank
전치를 취하면 Pᵀ=P여서 대칭이기도 합니다. 모든 멱등행렬이 유클리드 직교투영인 것은 아닙니다. 예를 들어 [[1,1],[0,0]]은 제곱해도 같지만 잔차가 가로축과 직교하지 않을 수 있습니다. 직교투영의 기하에는 대칭성까지 중요합니다.
X의 열이 종속이어도 Q로 만든 P는 여전히 정의됩니다. 마지막 역행렬식은 전체 조건이 맞을 때만 쓰는 표현입니다. 투영 그 자체의 존재와 특정 계산공식의 사용조건을 분리하세요.
With orthonormal Q, set P=QQᵀ. Applying it twice gives the same result because projected vectors already lie in the subspace. This is idempotence.
P=QQT,PT=P,P2=P,P=X(XTX)−1XTif X has full column rank
The matrix is also symmetric. Idempotence alone is insufficient for Euclidean orthogonal projection: [[1,1],[0,0]] is idempotent but can leave a residual not perpendicular to its range.
The Q-based projector still exists for a rank-deficient design. Only the final inverse expression requires full column rank. Distinguish existence from the conditions of one formula.
기초Foundations
21. 절편이 있으면 잔차합이 0인 이유21. Why an intercept makes residuals sum to zero
상수 1벡터가 열공간에 포함되면 잔차와의 내적이 0이므로 Σeᵢ=0입니다. 단순히 최소제곱이라는 이름만으로 언제나 잔차합이 0인 것은 아닙니다. 절편 없는 한 방향 비례모형에는 다른 직교조건만 있을 수 있습니다.
1∈Col(X)⟹i∑ei=0,∥y−yˉ1∥2=∥y−yˉ1∥2+∥e∥2
위 분해는 절편을 포함한 비가중 최소제곱에서 성립합니다. ȳ1도 열공간 안에 있으므로 적합값의 평균 주변 조각과 잔차가 직교하기 때문입니다. 왼쪽이 양수이면 훈련자료의 R²=1−SSE/SST를 만들 수 있고 0~1입니다. y가 모두 같아 SST=0이면 이 비율은 정의되지 않습니다.
이 분해를 절편 없는 모형이나 시험자료에 무조건 적용하지 않습니다. 높은 훈련 R²도 좋은 외부 예측이나 인과설명을 자동 보장하지 않습니다. 여기서는 내적이 어떤 대수적 등식을 만드는지까지만 확인합니다.
If the constant vector belongs to Col(X), residual orthogonality gives Σeᵢ=0. Least squares without an intercept need not have zero residual sum.
1∈Col(X)⟹i∑ei=0,∥y−yˉ1∥2=∥y−yˉ1∥2+∥e∥2
For unweighted least squares with an intercept, this decomposition follows because the centered fitted component lies in the column space. If SST is positive, training R²=1−SSE/SST lies in [0,1]. Constant outcomes make this ratio undefined.
Do not transfer the identity automatically to no-intercept models or test data. A high training R² alone establishes neither external predictive performance nor causality.
기초Foundations
22. 단위변환·특성척도·관측가중치는 다르다22. Separate units, feature scaling and observation weights
출력 kg를 g로 바꾸면 모든 잔차는 1000배, SSE는 10⁶배가 됩니다. 같은 자료의 같은 비가중 문제라면 최적 직선도 같은 물리적 관계를 표현합니다. 입력 mm를 cm로 바꾸면 기울기의 숫자와 단위가 바뀌어야 합니다.
SSEw=i∑wiei2=∥D1/2(y−Xβ)∥2,D=diag(wi),wi>0
한 특성 열을 10으로 나누는 것과 한 관측 행의 오차에 가중치 10을 주는 것은 다릅니다. 가역적인 열의 재표현은 같은 열공간을 유지할 수 있지만, 관측가중치는 어떤 점의 오차를 더 중요하게 볼지 바꾸므로 일반적으로 적합값도 바꿉니다.
양의 관측가중치라면 위와 같이 각 행과 y를 √wᵢ배해 다른 유클리드 문제로 바꿀 수 있습니다. 모든 가중치를 같은 양수배 하면 최적점은 같지만 목적값은 배율만큼 달라집니다. 어떤 가중치가 올바른지는 질문·측정·표집 설계에 관한 근거가 필요합니다.
Changing kg outcomes to grams multiplies residuals by 1000 and SSE by a million, while preserving the physical fitted relation. Changing mm inputs to cm changes the numerical slope and its unit.
SSEw=i∑wiei2=∥D1/2(y−Xβ)∥2,D=diag(wi),wi>0
Rescaling a feature column differs from weighting an observation's error. An invertible column reparameterization can preserve the column space; observation weighting generally changes which fit is preferred.
Positive weights can be implemented by multiplying each row and outcome by √wᵢ. Scaling all weights equally preserves minimizers but rescales the objective. Choosing weights requires substantive measurement or design justification.
기초Foundations
23. 실제 342개 펭귄 관측을 준비하기23. Prepare 342 actual penguin observations
고정된 공개 Palmer 펭귄 CSV 344행에서 flipper_length_mm와 body_mass_g가 모두 기록된 342행을 사용합니다. 성별 결측을 추가 배제하지 않습니다. 입력 x는 날개 길이 mm, 출력 y는 질량을 1000으로 나눈 kg입니다. 각 관측의 row_id를 유지합니다.
Xi=(1,xi−200),yi=body_mass_gi/1000,m=342
200 mm는 해석하기 가까운 기준이며 실제 평균 x̄≈200.915205 mm와 같지 않습니다. 따라서 두 설계열을 정확히 직교시킨 것은 아닙니다. 첫 계수 c는 200 mm에서의 적합 질량으로 읽으며, 자료 밖 x=0에서의 질량이라고 읽는 오류를 피합니다.
여러 종과 섬을 합친 기술적 일차 적합입니다. 종 차이·성별·연도 등 다른 특성을 통제한 추정이 아닙니다. 이 자료사본의 관계를 계산했다는 사실을 모든 펭귄 모집단의 생물학적 법칙이나 원인효과로 확대하지 않습니다.
Use the 342 rows complete on flipper_length_mm and body_mass_g from the fixed 344-row Palmer CSV. Do not additionally exclude missing sex. Inputs are flipper length in mm, outcomes body mass in kg, retaining row_id.
Xi=(1,xi−200),yi=body_mass_gi/1000,m=342
The convenient 200 mm reference differs from mean x̄≈200.915205 mm, so the two design columns are not exactly orthogonal. The first coefficient describes a fit at 200 mm, avoiding an unsupported interpretation at x=0.
This is a pooled descriptive linear fit across species and islands, not an adjusted biological or causal model. The snapshot's association does not establish a population law.
기초Foundations
24. 실제 적합·잔차·제곱합을 한 행씩 확인하기24. Inspect actual fitted values, residuals and squared error
기록된 소수를 정확한 유리수로 계산하면 아래 계수입니다. 화면 설명에는 반올림값 c≈4.156282 kg, b≈0.049686 kg/mm를 먼저 사용합니다. 재현 코드의 정밀계수와 표시값을 구별하세요. 부동소수 라이브러리끼리 끝자리 차이가 조금 날 수 있습니다.
row 1은 x=181 mm, y=3.75 kg입니다. 정밀계수로 계산한 적합은 약 3.212256 kg, 잔차는 약 0.537744 kg입니다. 모든 행의 제곱잔차를 더한 최솟값은 약 52.854796 kg²입니다. 1개 잔차가 양수라고 해서 전체 잔차합도 양수라는 뜻은 아닙니다.
정확한 산술에서 Σe=0, Σ(x−200)e=0입니다. 일반적인 컴퓨터 계산에서는 아주 작은 반올림 잔차가 남을 수 있으므로 단위와 크기를 고려해 검산합니다. c,b를 바꾼 현재 SSE를 최적 SSE와 비교하되 실측 y는 바꾸지 않습니다.
중심 없는 표현의 a는 약 −5.780831 kg입니다. 이것은 같은 직선의 대수적 절편이지 0 mm 펭귄의 실제 질량을 뜻하지 않습니다. 앞 장의 미분모형 기울기는 이 적합함수의 변화율이며, 실제 개체를 1 mm 늘리는 인과실험의 효과가 아닙니다.
Exact rational calculations on recorded decimals give the coefficients below. Explain them first as rounded c≈4.156282 kg and b≈0.049686 kg/mm. Reproduction coefficients differ from display rounding; floating libraries may differ slightly in final digits.
Row 1 has x=181 mm and y=3.75 kg. The precise fit is about 3.212256 kg, leaving residual 0.537744 kg. Summed squared residuals reach a minimum of about 52.854796 kg².
Exact arithmetic gives Σe=Σ(x−200)e=0. Floating computations may leave tiny discrepancies, to be checked with units and scales. Compare altered c,b loss against the optimum without changing observed y.
The equivalent uncentered intercept a≈−5.780831 kg is algebraic, not an observed mass for a zero-length penguin. The earlier derivative describes this fitted function, not a causal experiment enlarging an individual.
기초Foundations
25. 잘 맞는 숫자와 설명·예측의 근거25. A good numerical fit needs a separate interpretation
관측에서 최적 직선을 계산하는 것, 새 관측을 예측하는 것, 원인을 설명하는 것은 서로 다른 질문입니다. 이 장의 실제 실습은 첫 질문을 정확하게 수행합니다. 같은 342행을 적합하고 점검했으므로 독립 시험자료에서 성능을 확인한 실험은 아닙니다.
잔차가 커 보이는 행을 바로 삭제하지 마세요. 기록 오류인지, 다른 종의 특징인지, 비선형성인지 자료와 질문을 검토해야 합니다. 관측을 제외하면 기준·이유·전후 결과를 남겨야 합니다. SSE를 낮추고 싶다는 이유만으로 정보를 없애면 학습목적도 바뀝니다.
표준오차·신뢰구간·검정은 표집과 오차구조의 가정을 요구하며 통계·계량경제학에서 전개합니다. 지금 배운 직교성은 그 이론의 계산 뼈대가 되지만, 내적 0이 오차들의 확률적 독립이나 정규성을 증명하지는 않습니다.
Fitting current observations, predicting new ones and explaining causes are different questions. This chapter performs the first. Fitting and inspecting the same 342 rows is not an independent test-set evaluation.
Do not delete a large-residual record automatically. Investigate data errors, species differences or model misspecification. Document exclusion rules and before-after results rather than removing information solely to reduce SSE.
Standard errors, intervals and tests require sampling and error assumptions developed in statistics and econometrics. Orthogonal residuals provide algebraic structure, not a proof of probabilistic independence or normality.
기초Foundations
26. 계산 실무: 정규방정식과 안정적인 풀이를 구별하기26. Distinguish the equations from a stable numerical algorithm
정규방정식은 최적조건을 보여 주지만 XᵀX를 직접 만든 뒤 역행렬을 계산하는 것이 언제나 좋은 알고리즘은 아닙니다. 열이 거의 종속이면 정보를 더 약하게 만들 수 있습니다. 실무에서는 QR·SVD 기반 최소제곱을 사용하고 반환된 랭크·특이값·잔차를 함께 확인합니다.
Python에서는 NumPy의 linalg.lstsq, R에서는 qr 기반 풀이 또는 lm 같은 함수를 사용하되 입력·절편·결측 처리·랭크 규칙을 확인합니다. 함수가 계수 하나를 반환해도 수학적으로 유일한지, 어떤 대표해를 골랐는지 구별해야 합니다.
재현 기록에는 CSV 해시, 342행 선택 규칙, kg 변환, 기준 200 mm, 목적함수, 계수, SSE, Xᵀe 검산을 남깁니다. 이 장의 정확한 유리수 검산은 기록된 값의 산술 기준이며 측정 자체가 오차 없다는 뜻은 아닙니다.
Normal equations express optimality, but explicitly forming and inverting XᵀX is not always a good numerical algorithm. Near-dependent columns can worsen numerical difficulties. Use suitable QR/SVD solvers and inspect rank, singular values and residuals.
For example, use NumPy linalg.lstsq or R QR-based tools/lm while checking intercepts, missingness and rank policies. A returned coefficient vector may be one chosen representative rather than a mathematically unique answer.
Record the CSV hash, 342-row selection, kg conversion, 200 mm reference, objective, coefficients, SSE and Xᵀe checks. Exact rational arithmetic verifies recorded numbers without claiming perfect measurement.
기초Foundations
27. 국가·가구·기업의 직교투영 사례27. Country, household and company projection cases
국가 사례 · 11년의 실측값을 “가장 가까운 직선”으로 요약하기
한국의 2014~2024년 1인당 실질 GDP를 고정 사본에서 모두 선택합니다. 단위는 2015년 불변 USD/명이며 임금·개인소득·PPP가 아닙니다. 들쭉날쭉한 실제 값 11개를 한 직선으로 완전히 통과시키려는 대신, 선택한 11년의 제곱 차이 합을 가장 작게 만드는 직선을 찾습니다. 이는 이미 관측한 기간을 요약하는 기술적 모형입니다.
1. 직선도 관측 개수만큼의 긴 벡터가 된다
2019년을 중심으로 u=연도−2019라고 쓰면 u는 −5부터 5까지입니다. 모든 직선의 적합값은 a1+b u입니다. 따라서 관측벡터 y를 두 방향 1과 u가 만드는 부분공간에 투영하는 문제가 됩니다. 여기서 “직선”은 연도–GDP 그림에 그린 선이고, 투영은 11개 관측값을 성분으로 가진 공간에서 계산한다는 두 관점을 연결하세요. 연도를 고정한 세로 방향의 GDP 차이를 제곱해 더하는 것이 목표입니다. 연도–GDP 그림에서 각 점을 기울어진 선에 수직으로 내린 최단거리의 제곱을 최소화하는 문제와는 다르며, 여기서 직교는 11차원 관측공간에서의 뜻입니다.
앞 장들과 같은 UCI 공개 자료의 완전한 하루, 2006년 12월 17일의 1,440개 분평균 전력(kW)을 사용합니다. 원문 시 표기별로 60개씩 묶은 평균을 q₀,…,q₂₃으로 만듭니다. 이는 실제 분평균에서 계산한 시간 묶음 평균이며 순간 피크를 측정한 값이 아닙니다. 원문 시각의 시간대나 각 분의 시작·끝 정렬을 새로 가정하지 않습니다.
계산한 c는 약 2.354486111 kW입니다. 24차원 자료에서 한 방향인 1을 따라 움직일 수 있게 한 최소제곱 투영입니다. 실제 전력이 하루 내내 일정했다고 관측한 것은 아닙니다. 시간 묶음의 길이가 모두 1시간이므로 이 상수 모형의 하루 에너지는 c×24시간=56.507666667 kWh로 원자료 합과 같습니다.
실제 시간 묶음 평균과 상수 투영: 일부 기록
원문 시 표기
60분 평균 kW
상수 적합 kW
잔차 kW
00
1.882467
2.354486
-0.472019
06
1.303300
2.354486
-1.051186
12
1.915867
2.354486
-0.438619
18
3.697100
2.354486
1.342614
23
0.437733
2.354486
-1.916753
먼저 생각한 뒤 풀이 보기: 상수 c를 0.1 kW 더 크게 정하면 손실은 어떻게 달라질까요?
h∑(qh−c−0.1)2=h∑(qh−c)2+24(0.1)2
최적 c에서 잔차합이 0이므로 교차항이 사라집니다. 제곱합은 0.24 kW²만큼 커집니다. 여기서 손실은 시간평균 전력의 제곱차이며 전기요금이나 kWh 자체와는 다른 양입니다.
2. 길이가 다른 묶음에서는 같은 표도 다른 질문이 된다
같은 하루를 이번에는 원문 시 표기 00~05의 360분과 06~23의 1,080분으로 묶습니다. 두 평균값에 같은 가중치를 주는 것은 “두 묶음”을 동등하게 대하는 질문입니다. 하루 전체의 시간평균을 유지하려면 묶음의 실제 길이 6시간·18시간을 반영해야 합니다.
먼저 생각한 뒤 풀이 보기: 두 묶음 평균을 그냥 더해 2로 나누면 왜 다른 값이 나오나요?
무가중 평균은 약 2.274870370 kW입니다. 이것도 “두 숫자에 같은 가중치를 주는 손실”에는 맞지만, 6시간과 18시간을 같은 길이처럼 취급하므로 하루의 시간평균과는 다릅니다. 시간 가중치 W=diag(6,18)를 쓰면 가중 잔차합 6eA+18eB=0이고 원자료 에너지를 보존합니다.
1TWe=0,W=diag(6,18)
가중치는 단순한 장식이 아니라 무엇을 가깝다고 보는지의 정의입니다. 여기서는 기간을 반영하는 양의 가중치이며, 오차 분산을 추정해 만든 통계 가중치라고 주장하지 않습니다. 한 가구의 하루를 요약한 결과를 전국 가구의 전력이나 개인의 생활 습관으로 일반화하지 않습니다.
Apple FY2023·FY2024의 공시 순매출을 앞 장과 같은 다섯 품목 순서로 놓습니다. x는 FY2023 실제 벡터, z는 FY2024 실제 벡터입니다. 단위는 백만 명목 USD입니다. 이제 “다섯 품목이 같은 α배였다면”이라는 한 방향의 참조 모형 αx를 정하고, 실제 z와 가장 가까운 α를 찾습니다. 이것은 실제 공시 전체를 본 뒤 만든 구성 비교이며 사전 예측이나 기업 가치 평가가 아닙니다.
x는 영벡터가 아니므로 분모가 양수이고 α는 유일합니다. 원점을 지나는 한 방향만 허용했으므로, 각 품목을 마음대로 따로 바꾸는 모형과는 다릅니다. α는 무차원이고 αx는 원래와 같은 매출 단위를 갖습니다.
실제 공시와 기술적 비례 참조 모형: 백만 USD
품목
FY2023 실제 x
FY2024 실제 z
참조 αx (실측 아님)
잔차 z−αx
iPhone
200,583
201,183
204,198.764
-3,015.764
Mac
29,357
29,984
29,886.197
97.803
iPad
28,300
26,694
28,810.144
-2,116.144
웨어러블·홈·액세서리
39,845
37,005
40,563.257
-3,558.257
서비스
85,200
96,169
86,735.838
9,433.162
먼저 생각한 뒤 풀이 보기: 서비스 잔차가 양수이면 “오류”이거나 서비스가 이만큼 더 벌었다고 해석할까요?
서비스 실제 공시 96,169가 비례 참조값 약 86,735.838보다 9,433.162 높다는 뜻입니다. 잔차는 선택한 동일배수 모형과 구성의 차이입니다. 원공시가 틀렸다는 뜻도 아니고 특정 행동의 인과효과도 아닙니다. 비교 기준을 바꾸면 잔차도 달라집니다.
먼저 생각한 뒤 풀이 보기: 국가 직선 사례처럼 이 잔차도 합이 반드시 0일까요?
xTe=0,1Te≈840.800122881=0
여기서는 잔차가 직교해야 할 방향이 x 하나뿐입니다. 모형에 1 방향의 절편을 넣지 않았으므로 잔차합 0은 보장되지 않습니다. 실제로 합은 위와 같이 0이 아닙니다. “최소제곱 잔차합은 언제나 0”이라는 암기는 조건을 빠뜨린 것입니다.
먼저 생각한 뒤 풀이 보기: 비례계수를 α보다 0.01 크게 바꾸면 왜 반드시 더 멀어지나요?
∥z−(α+0.01)x∥22=∥e∥22+(0.01)2∥x∥22
e와 x의 내적이 0이어서 교차항이 사라집니다. SSE는 약 115,228,189.236445 (백만 USD)²이고, 어느 다른 계수를 쓰더라도 이 한 방향 안에서는 더 작아지지 않습니다. 그러나 “이 모형 안의 최적”은 경영적으로 옳은 예측이나 객관적 우열을 보장하지 않습니다.
전체 매출비 391,035/383,285를 맞추는 것과 품목별 제곱차를 최소화하는 것은 목적이 달라 α가 같을 필요가 없습니다. FY2023은 53주, FY2024는 52주이며, 이 예는 기간 길이·가격 변화·물량·환율을 분리하지 않습니다. 차이는 매출 단위의 제곱으로 가중되므로 큰 품목의 절대 차이가 손실에 더 큰 영향을 줍니다. 품목 비중이나 다른 가중치로 바꾸면 다른 투영 문제입니다.
Country case · Summarize eleven observed years with the closest line
Select every Korean real-GDP-per-capita observation from 2014 through 2024 in the fixed snapshot. Units are constant 2015 USD/person, not wages, personal income or PPP dollars. Instead of forcing one line through all eleven observations, minimize their sum of squared differences. This is a descriptive fit to an already observed period.
1. A line becomes a vector with one entry per observation
Center time at 2019: u=year−2019 runs from −5 to 5. Every fitted line has vector a1+b u, so project observed y onto the span of the two directions 1 and u. The line on a year–GDP plot and the projection in eleven-dimensional observation space are two views of the same fit. The objective holds each year fixed and minimizes squared vertical GDP differences. It does not minimize squared shortest perpendicular distances to the sloping line in the year–GDP plot; orthogonality here refers to the eleven-dimensional observation space.
The u-values sum to zero and their squares sum to 110, making the columns orthogonal. Solve the normal equations directly without constructing an inverse. The two independent columns give unique coefficients here.
XTX=[1100110],a=11∑yi,b=110∑uiyi
G(t)≈33290.08977875+754.47592853(t−2019)
The intercept a is the fitted value at 2019, not necessarily the actual 2019 observation. The slope has constant 2015 USD/person/year units. About 754.48 describes the fitted historical trend, not each year’s actual increment or a causal policy effect.
Observations and in-sample line: displayed values rounded
Year
Observed GDP/person
Fitted line
Residual = observed−fitted
2014
29,470.67
29,517.71
-47.04
2015
30,171.79
30,272.19
-100.40
2016
31,005.41
31,026.66
-21.25
2017
31,979.90
31,781.14
198.76
2018
32,852.89
32,535.61
317.27
2019
33,496.31
33,290.09
206.22
2020
33,215.93
34,044.57
-828.64
2021
34,792.94
34,799.04
-6.10
2022
35,809.01
35,553.52
255.50
2023
36,347.70
36,307.99
39.71
2024
37,048.43
37,062.47
-14.04
Think first, then reveal: How can optimality be checked beyond judging whether the residuals look small?
1Te=0,uTe=0,e=y−y
Both inner products are exactly zero using rational arithmetic on the retained inputs. The residual is perpendicular to both model directions. Summing displayed rounded residuals may leave a small discrepancy. SSE is about 949,168.605184 (2015 USD/person)².
Think first, then reveal: Could moving the entire optimal line up by 100 USD/person improve it?
∥e−1001∥22=∥e∥22+11(100)2
The cross term vanishes because e is orthogonal to 1. SSE increases by exactly 110,000. This concretely verifies why an orthogonal residual identifies the closest point in observation space.
Think first, then reveal: Does a small residual establish an accurate 2025 forecast or a successful policy?
No. The fit uses all eleven years and evaluates the same data. There is no future holdout or policy comparison group. Time dependence, structural change and statistical revisions remain. No out-of-sample forecast, confidence interval or causal inference is made here.
Household case · Why does the closest constant equal a mean?
Use the same complete UCI day, 17 December 2006, with 1,440 reported minute-average powers in kW. Average the sixty records with each hour label to obtain q₀,…,q₂₃. These are derived group means, not instantaneous peaks. No unsupported timezone or start/end alignment of minute timestamps is introduced.
The result is about 2.354486111 kW: a least-squares projection of 24 observations onto the direction 1. It does not observe constant actual power throughout the day. Because all groups contain one hour, c×24 hours=56.507666667 kWh preserves the observed daily energy sum.
Selected actual hourly means and constant projection
Source hour label
60-minute mean kW
Fitted constant kW
Residual kW
00
1.882467
2.354486
-0.472019
06
1.303300
2.354486
-1.051186
12
1.915867
2.354486
-0.438619
18
3.697100
2.354486
1.342614
23
0.437733
2.354486
-1.916753
Think first, then reveal: What happens to the loss if c is increased by 0.1 kW?
h∑(qh−c−0.1)2=h∑(qh−c)2+24(0.1)2
At the optimal c the residuals sum to zero, eliminating the cross term. The loss rises by 0.24 kW². This sum of squared power differences is distinct from energy in kWh or an electricity bill.
2. Unequal-duration groups change the weighting question
Regroup the same records into the 360 minutes with source hour labels 00–05 and the 1,080 minutes labeled 06–23. Equal weights treat two groups equally. To retain the whole-day mean over time, use their actual durations of six and eighteen hours.
Unequal-duration regrouping of the same observations
Think first, then reveal: Why does simply averaging the two group means give a different value?
The unweighted average is about 2.274870370 kW. It correctly minimizes an equal-weight two-number loss, but treats six and eighteen hours as equally long. It is not the whole-day time average. Duration weights W=diag(6,18) give weighted residual sum 6eA+18eB=0 and preserve observed energy.
1TWe=0,W=diag(6,18)
Weights define the meaning of closeness. These positive weights represent duration; they are not claimed to estimate statistical error variances. This one-household day does not establish national electricity use or an individual’s lifestyle.
Company case · Project this year onto a proportional reference of last year’s sales
Use the same five ordered categories of Apple’s reported net sales. Let x be the actual FY2023 vector and z the actual FY2024 vector, both in million nominal USD. Choose the one-direction reference “all categories multiplied by the same α” and find the closest αx to z. This comparison uses both disclosed years; it is neither an advance forecast nor a valuation.
The denominator is positive because x is nonzero, making α unique. Restricting the model to one direction through zero differs from allowing every category to change independently. α is dimensionless and αx retains sales units.
Actual filings versus a descriptive proportional reference: million USD
Category
FY2023 actual x
FY2024 actual z
Reference αx (not observed)
Residual z−αx
iPhone
200,583
201,183
204,198.764
-3,015.764
Mac
29,357
29,984
29,886.197
97.803
iPad
28,300
26,694
28,810.144
-2,116.144
Wearables, Home and Accessories
39,845
37,005
40,563.257
-3,558.257
Services
85,200
96,169
86,735.838
9,433.162
Think first, then reveal: Does a positive services residual mean an error or a causal gain?
The reported services figure 96,169 is 9,433.162 above the reference value of about 86,735.838. This measures composition relative to the chosen common-multiplier model. It does not mean the filing is wrong or an intervention caused that amount. Changing the reference changes the residual.
Think first, then reveal: Must these residuals sum to zero, as in the country-line example?
xTe=0,1Te≈840.800122881=0
Only the direction x is included, so the residual must be orthogonal to x. No intercept direction 1 is included; zero residual sum is not guaranteed and does not hold here. “Least-squares residuals always sum to zero” omits the required condition.
Think first, then reveal: Why must increasing α by 0.01 make this fit worse?
∥z−(α+0.01)x∥22=∥e∥22+(0.01)2∥x∥22
The cross term vanishes because e is orthogonal to x. SSE is about 115,228,189.236445 (million USD)². No different coefficient lowers it within this one-direction model. Mathematical optimality within a reference model does not establish a sound business forecast or an objective performance ranking.
Matching total sales by using 391,035/383,285 has a different objective from minimizing category-level squared differences, so its multiplier need not equal α. FY2023 has 53 weeks and FY2024 52; no adjustment separates duration, prices, quantities or exchange rates. Absolute differences in large categories influence this sales-unit loss more strongly. Shares or different weights define a different projection problem.
28. 재현 과제와 공식 참고 읽기28. Reproduction tasks and official readings
부분공간의 세 조건을 예·반례로 설명하고, 투영을 공간 안의 점과 직교잔차로 검산하세요. 같은 문제를 직교기저·정규방정식 두 방법으로 풀어 같은 적합벡터가 나오는지 확인합니다. 비직교기저에 단순 투영 합을 쓴 실패도 재현하세요.
실제 펭귄에서는 기록된 342행으로 계수를 다시 구하고 row 1의 잔차와 전체 SSE를 검산합니다. 중복 열을 추가해 계수는 여러 개지만 적합이 같은 상황을 만듭니다. 사례에서 절편이 없는 기업 비례모형의 잔차합도 살펴보면 ‘언제나 0’이라는 오해를 점검할 수 있습니다.
Explain subspace conditions through examples and counterexamples. Verify a projection lies in the space and leaves an orthogonal residual. Compare orthogonal-basis and normal-equation solutions; reproduce the failure of summing projections onto nonorthogonal directions.
Recompute the actual penguin fit, row 1 residual and total SSE. Add a duplicate column to separate coefficient from fitted-value uniqueness. The company case without an intercept also tests whether residual sums must always vanish.
The derivations and examples follow this route. Eigenvalues and positive semidefiniteness next, followed by SVD in Chapter 17, extend the story of squared loss, lost information and numerical stability.
자료 묶음을 풀고 코드와 실제데이터 폴더를 함께 두세요. 터미널에서 코드 파일이 있는 폴더로 이동해 아래 명령을 실행합니다. 코딩이 처음이라면 손계산과 웹 실습을 먼저 하고, 데이터 사이언스 입문에서 코드를 배운 뒤 돌아와도 됩니다.Extract the bundle, keeping the scripts beside the data folder. In a terminal, enter the script folder and run the commands below. Beginners can complete hand calculations and browser labs first, returning to code after studying introductory data science.
결과 파일은 각 코드에 지정된 결과 폴더에 저장됩니다. CSV 원자료는 덮어쓰지 않습니다.Result files are saved in the result directory specified by each script; the input CSVs are not overwritten.
영상·학자·함께 읽기Videos, thinkers and guided reading
본문의 질문을 넓히는 선택 학습입니다. 영상을 보기 전 질문을 먼저 읽고, 자신의 답을 쓴 뒤 해설과 비교하세요. 자료의 언어·선수 지식은 각 항목에 표시했습니다.Optional extensions to the chapter. Read the question first, write your answer, then compare with the explanation. Language and prerequisites are indicated below.
부분공간으로의 투영: 맞지 않는 식에서 가장 가까운 값 찾기Projections onto subspaces
MIT OpenCourseWare · Gilbert Strang · 18.06 Lecture 15
본문에서 재생되는 공식 영어 강의입니다. 한 방향의 정사영을 여러 열이 만드는 부분공간으로 확장합니다. 그림의 벡터를 이 장의 11개 GDP 관측값과 대응시켜 보세요.The official English lecture plays inside the chapter. Extend projection on one direction to a subspace spanned by several columns. Relate the geometry to the eleven GDP observations.
교재 안의 YouTube 플레이어에서 재생합니다. 원영상에서 제공하는 자막은 플레이어의 CC·설정에서 선택할 수 있습니다.Playback stays in this chapter’s YouTube player. Available captions can be selected through CC/settings.
보고 읽은 뒤 답하기Respond after watching/reading두 계수를 맞추는 국가 직선 사례에서 잔차는 어떤 두 방향과 직교하나요?In the two-coefficient country fit, which two directions are orthogonal to the residual?
생각을 점검하는 해설Check your reasoning
설계행렬의 두 열인 1과 year−2019입니다. y−Xβ가 그 열공간에 직교한다는 것은 Xᵀe=0이라는 두 방정식입니다.The columns 1 and year−2019. Orthogonality of y−Xβ to their column space means the two normal equations Xᵀe=0.
예르겐 페데르센 그람 · 직교화와 실무 문제의 연결Jørgen Pedersen Gram: orthogonality and practical problems
University of St Andrews · MacTutor
대학 아카이브는 그람(1850–1916)의 직교화 연구와 보험 실무·수치계산의 연결을 소개합니다. 이름이 붙은 절차도 앞선 연구와 이어진다는 점을 함께 읽습니다.The university archive introduces Gram (1850–1916), orthogonalization, and links between insurance work and numerical mathematics. It also notes the process had earlier antecedents.
보고 읽은 뒤 답하기Respond after watching/reading국가 설계행렬의 두 열을 직교하게 중심화하면 무엇이 쉬워지나요?What becomes easier when centering makes the country design columns orthogonal?
생각을 점검하는 해설Check your reasoning
XᵀX의 두 비대각 성분이 0이어서 평균과 기울기를 각각 계산할 수 있습니다. 직교화는 계산을 정리하지만 데이터의 인과 해석을 만들어 주지는 않습니다.The off-diagonal entries of XᵀX vanish, separating mean and slope calculations. Orthogonality simplifies algebra without establishing causality.
직교분해와 가장 가까운 벡터Orthogonal decomposition and the closest vector
Georgia Tech · Interactive Linear Algebra §6.3
직교분해 정리와 한 직선으로의 투영 공식을 읽습니다. 기업의 실제 z를 참조 αx와 직교 잔차로 나누는 계산을 직접 확인하세요.Read the orthogonal-decomposition theorem and line-projection recipe. Verify how actual company vector z splits into reference αx and an orthogonal residual.
보고 읽은 뒤 답하기Respond after watching/reading기업 잔차를 원래 방향 x에 다시 투영하면 무엇이 나오나요?What is the projection of the company residual onto x?
생각을 점검하는 해설Check your reasoning
x≠0이고 xᵀe=0이므로 투영계수는 0, 투영벡터도 영벡터입니다. 이는 선택한 방향 안에 남은 차이가 없다는 뜻입니다.Because x is nonzero and xᵀe=0, the projection coefficient and vector are zero. No residual component remains in that chosen direction.
최소제곱의 해와 계수의 유일성 조건Least-squares solutions and coefficient uniqueness
Georgia Tech · Interactive Linear Algebra §6.5
최소제곱과 정규방정식의 연결, 독립인 열일 때의 유일성 조건을 읽습니다. 고유한 적합벡터와 계수 유일성이 어떤 조건에서 구별되는지 확인합니다.Read the normal equations and the independent-column condition for unique coefficients. Distinguish uniqueness of the fitted projection from uniqueness of its coefficients.
보고 읽은 뒤 답하기Respond after watching/reading설계행렬에 같은 열을 한 번 더 붙이면 투영값과 계수는 어떻게 될까요?What if an identical column is appended to the design matrix?
생각을 점검하는 해설Check your reasoning
열공간은 그대로이므로 같은 유클리드 투영값을 얻지만, 중복한 두 열의 계수 합만 정해질 수 있어 개별 계수는 유일하지 않습니다.The column space and Euclidean projection stay the same, but coefficients of duplicate columns need not be unique; only their combined contribution is fixed.
연습문제 · 계산에서 설명과 증명까지Exercises: calculation, explanation and proof
먼저 혼자 풀고 풀이를 여세요. 숫자와 함께 단위·포함 기준·계산 이유를 확인하세요.Attempt each problem before opening its solution. Check units, inclusion rules and the reason for the calculation.
1. 부분공간의 조건Subspace conditions
W={(x,2x):x∈ℝ}가 부분공간임을 0·합·상수배로 확인하세요.
Verify that W={(x,2x):x∈ℝ} is a subspace.
풀이와 확인할 이유Solution and explanation
x=0에서 0이 있습니다. (a,2a)+(b,2b)=(a+b,2(a+b))도 같은 꼴이고, c(a,2a)=(ca,2ca)도 같습니다. 세 조건을 모두 만족합니다. 그림이 직선처럼 보인다는 사실 대신 연산으로 검증했습니다.
Zero is included. Sums have form (a+b,2(a+b)), and scalar multiples have form (ca,2ca). All required closure conditions hold.
2. 원점을 지나는지 확인하기Check the origin
y=2x+1인 점들의 모임은 부분공간인가요?
Is the line y=2x+1 a vector subspace?
풀이와 확인할 이유Solution and explanation
(0,0)이 식을 만족하지 않으므로 아닙니다. 아핀 직선이지만 벡터 부분공간은 아닙니다. 점들이 일직선이라는 관찰만으로 원점 조건을 생략할 수 없습니다.
No. It does not contain the zero vector. It is an affine line, not a vector subspace.
3. 0을 포함해도 충분하지 않다Containing zero is insufficient
W={(x,y):x≥0,y≥0}는 0을 포함합니다. 부분공간인가요?
Does the nonnegative quadrant form a subspace?
풀이와 확인할 이유Solution and explanation
(1,0)은 W에 있지만 −1배한 (−1,0)은 없습니다. 모든 실수배에 닫히지 않아 부분공간이 아닙니다. 하나의 필요조건만 확인해서는 충분하지 않습니다.
No. It contains (1,0) but not its negative. Closure under all real scalar multiples fails.
4. 생성공간의 세 가지 경우Three possible spans
평면에서 (0,0),(0,0), 또는 (1,2),(2,4), 또는 (1,0),(0,1)의 생성공간을 각각 설명하세요.
Describe spans of the pairs zero/zero, (1,2)/(2,4), and the standard planar directions.
풀이와 확인할 이유Solution and explanation
첫째는 0 하나, 둘째는 (1,2)의 모든 배수인 직선, 셋째는 평면 전체입니다. 목록 길이는 모두 둘이지만 독립적인 방향 수는 0,1,2로 다릅니다.
They are the zero space, a line, and the entire plane. Two listed generators can provide zero, one or two independent directions.
5. 기저 좌표가 달라도 벡터는 같다Different coordinates, same vector
Represent (2,0) using basis (1,1),(1,−1) and compare standard coordinates.
풀이와 확인할 이유Solution and explanation
v₁+v₂=(2,0)이므로 새 좌표는 (1,1)입니다. 표준기저 좌표는 (2,0)입니다. 좌표값은 기준방향에 따라 달라지지만 나타내는 원래 벡터는 같습니다.
The new coordinates are (1,1), because the basis vectors sum to (2,0). Standard coordinates are (2,0). The represented vector is unchanged.
6. 공간의 차원을 구별하기Distinguish ambient dimensions
관측 5개에 절편과 기울기 2개를 적합합니다. X, β, ŷ는 각각 어떤 크기인가요?
State the shapes of X, β and ŷ for five observations with intercept and slope.
풀이와 확인할 이유Solution and explanation
X는 5×2, β는 길이 2, ŷ=Xβ는 길이 5입니다. 적합벡터는 관측공간 ℝ⁵에 있습니다. 두 계수의 공간이나 2차원 산점도와 같은 공간이라고 섞지 않습니다.
They are 5×2, 2×1 and 5×1. Fitted values live in observation space ℝ⁵, distinct from coefficient space and the scatterplot plane.
7. 직교여공간을 행렬로 검산하기Check an orthogonal complement
X=[[1,0],[0,1],[0,0]], r=(0,0,3)에서 Xᵀr을 구하세요.
For X=[[1,0],[0,1],[0,0]], r=(0,0,3), compute Xᵀr.
풀이와 확인할 이유Solution and explanation
두 성분이 모두 0입니다. r은 X의 두 열과 직교하므로 그 조합인 xy평면 전체와 직교합니다. 한 기저를 확인하면 모든 조합이 따라옵니다.
The result is (0,0). Orthogonality to both basis columns implies orthogonality to their whole span, the xy-plane.
8. 평면 투영과 제곱길이Plane projection and squared lengths
u=(2,−1,3)을 xy평면에 투영해 p,r을 구하고 피타고라스를 확인하세요.
Project (2,−1,3) onto the xy-plane and check Pythagoras.
풀이와 확인할 이유Solution and explanation
p=(2,−1,0), r=(0,0,3)입니다. 제곱길이는 14,5,9로 14=5+9입니다. 잔차는 평면의 모든 방향과 직교합니다.
The projection is (2,−1,0), residual (0,0,3), with squared lengths 14=5+9.
9. 다른 후보와 가장 가까운 점 비교Compare another candidate
앞 문제의 다른 평면 점 w=(1,1,0)에 대해 ‖u−w‖²를 구하고 투영거리와 비교하세요.
For the preceding u and projection p, compare w=(1,1,0) using squared distances.
풀이와 확인할 이유Solution and explanation
u−w=(1,−2,3)이므로 제곱거리는 14입니다. 투영까지의 제곱거리 9에 ‖p−w‖²=1²+(−2)²=5가 더해진 14=9+5입니다. 후보를 바꾸어도 추가항은 음수가 될 수 없습니다.
The candidate gives 14=9+5: the optimal residual squared plus ‖p−w‖². The additional term cannot be negative.
10. 직교 목록에서 0을 빼는 이유Why an orthogonal basis excludes zero
(1,0),(0,0)은 내적이 0입니다. 정규직교기저라고 부를 수 있나요?
Can (1,0),(0,0) be an orthonormal basis just because their dot product is zero?
풀이와 확인할 이유Solution and explanation
없습니다. 둘째 벡터는 길이 0이고 독립성도 어깁니다. 직교 목록을 기저로 쓸 때는 비영벡터를 요구하고, 정규직교에는 각각 길이 1까지 요구합니다. 영벡터의 대수적 직교와 기저 조건은 다릅니다.
No. The zero member is not unit length and makes the list dependent. Algebraic orthogonality alone does not satisfy basis conditions.
11. QᵀQ와 QQᵀ의 차이QᵀQ versus QQᵀ
Q=[[1,0],[0,1],[0,0]]에서 두 곱을 구하세요.
Compute both products for Q=[[1,0],[0,1],[0,0]].
풀이와 확인할 이유Solution and explanation
QᵀQ=I₂입니다. 반대 곱 QQᵀ=diag(1,1,0)으로 I₃가 아닙니다. 이는 xy평면으로의 투영이며 z성분을 지웁니다. 직사각형 차원과 다루는 공간을 확인해야 합니다.
QᵀQ=I₂, whereas QQᵀ=diag(1,1,0). The latter projects onto the xy-plane rather than preserving the whole three-dimensional space.
12. 직교기저로 투영 합하기Projection with an orthogonal basis
u=(3,1,2)를 W=span((1,1,0),(0,0,1))에 투영하세요.
Project (3,1,2) onto span((1,1,0),(0,0,1)).
풀이와 확인할 이유Solution and explanation
첫 계수는 (3+1)/2=2, 둘째는 2/1=2입니다. p=(2,2,2), r=(1,−1,0)입니다. 두 방향과 잔차 내적이 모두 0이고, 제곱길이 14=12+2입니다.
The coefficients are 2 and 2, giving p=(2,2,2), r=(1,−1,0). Both residual dot products vanish, and 14=12+2.
13. 비직교기저에 공식을 잘못 쓰면Misusing the projection formula
u=(0,1), v₁=(1,0),v₂=(1,1)에서 두 직선 투영의 합과 올바른 평면 투영을 비교하세요.
Compare summed line projections with the true span projection for u=(0,1), v₁=(1,0),v₂=(1,1).
풀이와 확인할 이유Solution and explanation
직선 투영 합은 (1/2,1/2)입니다. 그러나 두 방향의 생성공간은 평면 전체이므로 올바른 투영은 (0,1)입니다. 잘못 만든 잔차 (−1/2,1/2)는 v₁과 직교하지 않습니다. 단순 합 공식에는 직교기저가 필요합니다.
The sum is (1/2,1/2), but the true planar projection is u itself. The erroneous residual is not orthogonal to v₁. The simple formula requires an orthogonal basis.
14. Gram–Schmidt를 직접 하기Compute Gram–Schmidt
v₁=(1,1),v₂=(1,0)에서 q₁,z₂,q₂를 구하세요.
For v₁=(1,1),v₂=(1,0), find q₁,z₂,q₂.
풀이와 확인할 이유Solution and explanation
q₁=(1,1)/√2입니다. 둘째의 투영은 (1/2,1/2)이므로 z₂=(1/2,−1/2), 길이는 1/√2입니다. 따라서 q₂=(1,−1)/√2입니다. 두 단위벡터의 내적은 (1−1)/2=0입니다.
The results are q₁=(1,1)/√2, z₂=(1/2,−1/2), and q₂=(1,−1)/√2. Their unit lengths and zero dot product verify the construction.
15. 종속 입력의 0 잔차A dependent input leaves zero remainder
v₁=(1,1),v₂=(2,2)에 Gram–Schmidt를 적용하면 둘째 단계에서 무슨 일이 생기나요?
What happens at the second Gram–Schmidt step for (1,1),(2,2)?
풀이와 확인할 이유Solution and explanation
v₂ 전체가 첫 방향에 있으므로 투영을 빼면 z₂=0입니다. 0으로 나누어 새 단위벡터를 만들 수 없습니다. 공간은 직선 하나이므로 기저방향도 하나면 충분합니다. 일반 알고리즘은 이 열을 건너뛰고 이유를 기록할 수 있습니다.
The remainder is zero, so normalization is undefined. The span has only one direction; a general algorithm may skip the dependent column while documenting it.
Compare β₀=(1.4,1.2,0) and β₁=(1.4,−0.8,1) for columns one,x,2x.
풀이와 확인할 이유Solution and explanation
합성 기울기는 각각 1.2와 −0.8+2=1.2입니다. 두 계수는 다르지만 적합벡터와 SSE 0.8은 같습니다. 차이 (0,−2,1)은 영공간의 방향입니다.
Both give combined slope 1.2 and identical fitted values with SSE 0.8. Their difference (0,−2,1) is a null direction.
23. 역행렬 공식을 쓸 조건Conditions of the inverse formula
X에 중복 열이 있는데 (XᵀX)⁻¹Xᵀy 공식을 그대로 계산해도 될까요?
May (XᵀX)⁻¹Xᵀy be used unchanged with a duplicate column?
풀이와 확인할 이유Solution and explanation
중복 열은 비영 영방향을 만들고 XᵀX를 특이하게 하므로 그 역행렬이 없습니다. 최소제곱 적합벡터는 존재하지만 이 공식은 사용할 수 없습니다. 직교기저나 적절한 랭크 처리 알고리즘으로 구하고 대표계수의 규칙을 기록합니다.
No. XᵀX is singular. The fitted vector still exists; use an appropriate basis or rank-aware solver and disclose how a coefficient representative is selected.
24. 멱등성만으로 충분하지 않다Idempotence alone is insufficient
P=[[1,1],[0,0]]에서 P²와 u=(0,1)의 잔차 u−Pu를 구하세요.
For P=[[1,1],[0,0]], compute P² and the residual for u=(0,1).
풀이와 확인할 이유Solution and explanation
P²=P이지만 Pu=(1,0), 잔차는 (−1,1)입니다. 범위의 방향 (1,0)과 잔차 내적이 −1이라 직교하지 않습니다. P는 대칭이 아니며 유클리드 직교투영이라고 할 수 없습니다.
P²=P, but the residual is (−1,1), not orthogonal to the horizontal range. P is not symmetric and is not a Euclidean orthogonal projector.
25. 절편 없는 잔차합Residual sum without an intercept
y=(1,1)을 v=(1,2) 방향에 최소제곱 투영하세요. 잔차합이 0인가요?
Project y=(1,1) onto direction (1,2). Must residuals sum to zero?
풀이와 확인할 이유Solution and explanation
계수는 (1+2)/(1+4)=3/5입니다. 적합은 (0.6,1.2), 잔차는 (0.4,−0.2)여서 합이 0.2입니다. v와는 직교하지만 상수 1벡터가 이 직선의 방향이 아니므로 잔차합 0 조건은 없습니다.
The coefficient is 3/5, fit (0.6,1.2), residual (0.4,−0.2), sum 0.2. Orthogonality to the fitted direction does not imply orthogonality to the constant vector.
26. 훈련 R²와 0 분모Training R² and a zero denominator
가정 자료에서 SST=15.2, SSE=0.8일 때 훈련 R²를 구하세요. SST=0이면?
Find R² from toy SST 15.2 and SSE 0.8. What if SST=0?
풀이와 확인할 이유Solution and explanation
R²=1−0.8/15.2=18/19≈0.947368입니다. 절편을 포함한 이 훈련자료 분해에서 얻은 값입니다. SST=0이면 비율의 분모가 0이라 이 정의는 미정의입니다. 높은 값으로 새 자료 성능이나 인과성을 대신할 수 없습니다.
The result is 18/19≈0.947368. The ratio is undefined when SST=0. This training quantity is not evidence of external predictive performance or causality.
27. kg를 g로 바꾸면Convert kg outcomes to grams
최적 SSE가 52.85479562835483 kg²입니다. 출력 단위를 g로 바꾸면 SSE는 어떻게 될까요?
Convert SSE 52.85479562835483 kg² to squared grams.
풀이와 확인할 이유Solution and explanation
잔차가 1000배이므로 SSE는 10⁶배인 약 52854795.62835483 g²입니다. 다른 물리적 적합이 좋아지거나 나빠진 것이 아니라 단위가 바뀐 것입니다. 목적함수끼리 비교할 때 단위를 맞춰야 합니다.
Multiply by a million, obtaining about 52854795.62835483 g². This changes the numerical unit, not the physical fit quality.
28. 관측가중치를 모두 같은 배율로Multiply every observation weight equally
양의 가중치 wᵢ를 모두 3배 하면 최소화하는 계수와 목적값은 어떻게 되나요?
What changes if all positive weights are multiplied by three?
풀이와 확인할 이유Solution and explanation
모든 후보의 목적값이 동일하게 3배 되므로 최적계수 집합은 같습니다. 최소 목적값은 3배입니다. 특정 행만 3배 하는 경우는 상대적인 중요도가 달라져 같은 결론이 아닙니다.
The minimizing coefficient set is unchanged and the minimum objective triples. Changing only selected weights instead changes relative importance and generally the fit.
29. 실제 펭귄의 분석 표본The actual penguin analysis sample
펭귄 CSV의 344행 중 두 수치열이 있는 342행을 사용합니다. 이 실습에서 sex 결측을 제외하거나 질량을 이미 kg라고 읽어도 될까요?
May missing sex be excluded, or body_mass_g read directly as kg, in the stated 342-row experiment?
풀이와 확인할 이유Solution and explanation
둘 다 사전 규칙과 다릅니다. sex는 사용하지 않으므로 추가 배제하지 않습니다. body_mass_g를 1000으로 나누어 kg로 변환합니다. 선택과 단위가 바뀌면 같은 적합을 재현한 것이 아니므로 유효행과 변환을 기록합니다.
No. Neither matches the specified procedure. Use two-feature completeness without extra sex exclusion, and divide grams by 1000 for kg.
30. 기준 200 mm의 절편Interpret the 200 mm reference coefficient
ŷ=c+b(x−200), c≈4.156282, b≈0.049686에서 c의 단위와 뜻을 설명하세요.
Interpret c and its unit in ŷ=c+b(x−200), with c≈4.156282,b≈0.049686.
풀이와 확인할 이유Solution and explanation
c의 단위는 kg이고 200 mm에서의 모형 적합값입니다. b는 kg/mm입니다. c를 x=0에서의 질량이라고 읽으면 중심화 정의를 놓친 것입니다. 중심 없는 절편은 a=c−200b로 별도 계산합니다.
c is the fitted mass in kg at 200 mm. The slope is kg/mm. The uncentered intercept is a=c−200b, not c itself.
For x=181 mm,y=3.75 kg and precise fitted mass 3.2122561614270535 kg, find and interpret the residual.
풀이와 확인할 이유Solution and explanation
e=y−ŷ≈0.5377438385729465 kg입니다. 이 관측 질량이 해당 일차 적합보다 크다는 뜻입니다. 측정 오류나 인과효과라는 뜻은 아닙니다. 본문 반올림 계수로 다시 계산하면 마지막 자리 차이가 날 수 있습니다.
The residual is about 0.5377438385729465 kg. Observed mass exceeds this fitted value. That is not itself proof of measurement error or causality.
32. 수학적 0과 컴퓨터의 작은 값Exact zero versus a tiny computed value
실제 적합에서 Xᵀe의 한 성분이 10⁻¹¹ 정도로 나왔습니다. 즉시 최적조건 실패라고 해야 할까요?
A computed component of Xᵀe is about 10⁻¹¹. Is this automatically a failure?
풀이와 확인할 이유Solution and explanation
단위·자료 크기·계산 경로와 허용기준을 먼저 봅니다. 이 자료의 정확한 유리수 검산은 0이지만 부동소수 합은 작은 반올림을 남길 수 있습니다. 반대로 크기를 보지 않고 모든 작은 값을 무조건 0으로 지우는 것도 안 됩니다. 판정 기준을 기록합니다.
Check units, scale, calculation and tolerance. Exact rational references here are zero, while floating sums can leave small discrepancies. Neither automatic rejection nor arbitrary zeroing is justified.
33. 같은 적합과 새 관측의 예측Current fit versus new-observation prediction
342행 전체로 적합하고 같은 행의 잔차를 보았습니다. 이를 독립 시험자료 평가라고 부를 수 있을까요?
Does fitting all 342 rows and inspecting those residuals constitute independent test evaluation?
풀이와 확인할 이유Solution and explanation
아닙니다. 현재 자료에 대한 적합과 잔차 검산입니다. 새 자료 성능을 평가하려면 분리·전처리·목표·평가지표를 갖춘 다른 절차가 필요합니다. 훈련잔차의 직교성은 그 절차를 대신하지 않습니다.
No. It checks the current fit. Independent predictive evaluation requires its own split, preprocessing, target and metric. Training orthogonality does not replace it.
34. 내적 0이 증명하지 않는 것What zero dot products do not prove
잔차가 모든 설계열과 직교합니다. 이것으로 잔차들이 서로 독립이고 정규분포라고 결론낼 수 있나요?
Do these orthogonality conditions establish that the residuals themselves are independent and normally distributed?
풀이와 확인할 이유Solution and explanation
없습니다. 직교성은 선택한 제곱합을 최소화한 대수적 조건입니다. 확률적 독립·분포·인과적 외생성은 다른 가정과 근거가 필요합니다. 계산 조건과 연구의 확률모형을 구별해야 합니다.
No. Orthogonality is an algebraic optimality condition. Independence, distributions and causal exogeneity require separate assumptions and evidence.
35. 관측가중치가 바꾸는 상수 적합Observation weights change a constant fit
두 관측 y=(0,2)에 상수 c만 적합합니다. 비가중 기준과 가중치 (1,3) 기준의 최적 c를 비교하세요.
Fit a constant c to y=(0,2). Compare the unweighted optimum with weights (1,3).
풀이와 확인할 이유Solution and explanation
비가중에서는 평균 1입니다. 가중 목적은 c²+3(2−c)²=4(c−1.5)²+3이므로 최적 c=1.5입니다. 둘째 관측을 상대적으로 더 중요하게 보아 답이 달라졌습니다. 특성 열의 단위만 바꾼 것과 다른 변화입니다.
The unweighted mean is 1. The weighted loss is 4(c−1.5)²+3, minimized at 1.5. Giving one observation greater relative importance changes the fitted answer, unlike a mere feature-unit conversion.
World Bank · NY.GDP.PCAP.KD · 한국 실질 1인당 GDP · 1980–2024 · 2015년 불변 미국달러 · CC BY 4.0Korean real GDP per capita · 1980–2024 · constant 2015 US dollars · CC BY 4.0
자료별 확보일·원행 식별·단위·이용 조건은 출처 기록을 확인하세요. 학습 사본은 제공처의 현재 최신 자료와 다를 수 있습니다.Consult each source record for retrieval dates, row identifiers, units and terms. Teaching copies can differ from current provider releases.