如何用python写这个正交投影公式?[重复]

问题描述 投票:-1回答:1

矢量𝑥在一维子空间 𝑈上的投影,基矢量 𝑏。

𝜋𝑈(𝑥)=𝑏𝑏𝑇𝑏 "2𝑥

而对于一般投影到M维子空间𝑈上的基向量为

𝜋Lu_1D448𝐵(𝐵Lu_1D447𝐵)-1𝐵Lu_1D447 "𝑥。

哪儿

𝐵=[𝑏1,...,𝑏𝑀] 。

python numpy machine-learning pca orthogonal
1个回答
0
投票

当然可以

import numpy as np
v = np.array([1, 2, 3])
# Has to be a unit vector!
v = v/np.linalg.norm(v)

# Projection matrix unto the v direction
P = np.outer(v, v)

# Projection matrix unto the plane with a normal of v
T = np.eye(len(v)) - P
© www.soinside.com 2019 - 2024. All rights reserved.