Skip to content

Commit e23fec7

Browse files
committed
add normalize function
1 parent d1879f6 commit e23fec7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

wfdb/processing/basic.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,21 @@ def get_filter_gain(b, a, f_gain, fs):
230230
gain = abs(h[ind])
231231

232232
return gain
233+
234+
235+
def normalize(X):
236+
"""
237+
Scale input vector to unit norm (vector length).
238+
239+
Parameters
240+
----------
241+
X : ndarray
242+
The vector to normalize.
243+
244+
Returns
245+
-------
246+
ndarray
247+
The normalized vector.
248+
249+
"""
250+
return X / np.linalg.norm(X)

0 commit comments

Comments
 (0)