Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> U = Matrix([[1, 1], [1, -1], [1, 1], [1, -1]])
- >>> U
- ⎡1 1 ⎤
- ⎢ ⎥
- ⎢1 -1⎥
- ⎢ ⎥
- ⎢1 1 ⎥
- ⎢ ⎥
- ⎣1 -1⎦
- >>> w = Matrix([1, 2, -1, 2])
- >>> w
- ⎡1 ⎤
- ⎢ ⎥
- ⎢2 ⎥
- ⎢ ⎥
- ⎢-1⎥
- ⎢ ⎥
- ⎣2 ⎦
- >>> P = U * (U.T * U)**-1 * U.T
- >>> P
- ⎡1/2 0 1/2 0 ⎤
- ⎢ ⎥
- ⎢ 0 1/2 0 1/2⎥
- ⎢ ⎥
- ⎢1/2 0 1/2 0 ⎥
- ⎢ ⎥
- ⎣ 0 1/2 0 1/2⎦
- >>> (eye(4) - P) * w
- ⎡1 ⎤
- ⎢ ⎥
- ⎢0 ⎥
- ⎢ ⎥
- ⎢-1⎥
- ⎢ ⎥
- ⎣0 ⎦
- >>> P * w
- ⎡0⎤
- ⎢ ⎥
- ⎢2⎥
- ⎢ ⎥
- ⎢0⎥
- ⎢ ⎥
- ⎣2⎦
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement