BIZNIQUE / LINEAR ALGEBRA / 31
Measure perpendicular distance to a boundary
Measure perpendicular distance to a boundary
Move a line and distinguish perpendicular distance from a horizontal or vertical gap.
BIZNIQUE / LINEAR ALGEBRA / 31
Move a line and distinguish perpendicular distance from a horizontal or vertical gap.
THE IDEA
A line in two dimensions and a plane in three dimensions are examples of a hyperplane. The nearest point is reached along the normal direction. The formula requires w to be nonzero.
d = |wᵀx + b| / ‖w‖₂
The signed expression tells you which side of the boundary contains the point. The absolute value gives distance and discards that side information.
TRY IT YOURSELF
For x = (3, 4) and the line x₁ = 1, what is the perpendicular distance?
Use w = (1, 0), b = −1. The distance is |3−1| = 2.