GitHub

@@ -684,20 +684,57 @@ Numerical routines would in this case use the alternative form $R \hat \beta = Q

684684685685

## Exercises

686686687-

### Exercise 1

687+

```{exercise-start}

688+

:label: ex1

689+

```

688690689691

Show that, for any linear subspace $S \subset \mathbb R^n$, $S \cap S^{\perp} = \{0\}$.

690692691-

### Exercise 2

693+

```{exercise-end}

694+

```

695+696+

```{solution-start} ex1

697+

:class: dropdown

698+

```

699+

If $x \in S$ and $x \in S^\perp$, then we have in particular

700+

that $\langle x, x \rangle = 0$, but then $x = 0$.

701+702+

```{solution-end}

703+

```

692704705+

```{exercise-start}

706+

:label: ex2

707+

```

693708

Let $P = X (X' X)^{-1} X'$ and let $M = I - P$. Show that

694709

$P$ and $M$ are both idempotent and symmetric. Can you give any

695710

intuition as to why they should be idempotent?

696711697-

### Exercise 3

712+

```{exercise-end}

713+

```

714+715+

```{solution-start} ex2

716+

:class: dropdown

717+

```

718+719+

Symmetry and idempotence of $M$ and $P$ can be established

720+

using standard rules for matrix algebra. The intuition behind

721+

idempotence of $M$ and $P$ is that both are orthogonal

722+

projections. After a point is projected into a given subspace, applying

723+

the projection again makes no difference (A point inside the subspace

724+

is not shifted by orthogonal projection onto that space because it is

725+

already the closest point in the subspace to itself).

726+727+

```{solution-end}

728+

```

729+730+731+

```{exercise-start}

732+

:label: ex3

733+

```

698734699735

Using Gram-Schmidt orthogonalization, produce a linear projection of $y$ onto the column space of $X$ and verify this using the projection matrix $P := X (X' X)^{-1} X'$ and also using QR decomposition, where:

700736737+701738

$$

702739

y :=

703740

\left(

@@ -723,24 +760,14 @@ X :=

723760

\right)

724761

$$

725762726-

## Solutions

727-728-

### Exercise 1

729763730-

If $x \in S$ and $x \in S^\perp$, then we have in particular

731-

that $\langle x, x \rangle = 0$, but then $x = 0$.

764+

```{exercise-end}

765+

```

732766733-

### Exercise 2

734767735-

Symmetry and idempotence of $M$ and $P$ can be established

736-

using standard rules for matrix algebra. The intuition behind

737-

idempotence of $M$ and $P$ is that both are orthogonal

738-

projections. After a point is projected into a given subspace, applying

739-

the projection again makes no difference. (A point inside the subspace

740-

is not shifted by orthogonal projection onto that space because it is

741-

already the closest point in the subspace to itself.).

742-743-

### Exercise 3

768+

```{solution-start} ex3

769+

:class: dropdown

770+

```

744771745772

Here's a function that computes the orthonormal vectors using the GS

746773

algorithm given in the lecture

@@ -832,3 +859,8 @@ Py3

832859833860

Again, we obtain the same answer.

834861862+

```{solution-end}

863+

```

864+865+866+

Read the original on github.com ↗