← Back to NumPy Course | Chapter 7: Linear Algebra | Lesson 4 of 6

np.linalg.norm() से Norm निकालना

एक norm एक vector या matrix की length या size को एक single number की तरह measure करता है।

In this page:

  1. np.linalg.norm()
Syntax
python
length = np.linalg.norm(vector)
np.linalg.norm(vector, ord=p)

np.linalg.norm()

Default से norm एक vector की Euclidean (L2) length compute करता है, squares के sum का square root। ord argument अन्य norms select करता है जैसे 1 (absolute values का sum) या np.inf (सबसे बड़ी absolute value)।

Norms distances और error measurements के लिए इस्तेमाल होते हैं।

Note: दो points के बीच distance norm(a - b) है।

उदाहरण: np.linalg.norm()

python
import numpy as np

v = np.array([3, 4])
print(np.linalg.norm(v))
print(np.linalg.norm(v, ord=1))
print(np.linalg.norm(np.array([1, 2]) - np.array([4, 6])))

# Output:
# 5.0
# 7.0
# 5.0
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. यह भूल जाना कि ord definition बदलता है
  2. vector और matrix norms confuse करना
  3. एक distance measure करने से पहले subtract न करना
चैप्टर सारांश
  • Default L2 norm है
  • ord norm type select करता है
  • Distance difference के norm के बराबर है
  • Vectors और matrices पर काम करता है
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.