bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / cluster / vq / _vq_impl / whiten
function
scipy.cluster.vq._vq_impl:whiten
source: build-install/usr/lib/python3.14/site-packages/scipy/cluster/vq/_vq_impl.py:26
Signature
def whiten(obs, check_finite = None)Summary
Normalize a group of observations on a per feature basis.
Extended Summary
Before running k-means, it is beneficial to rescale each feature dimension of the observation set by its standard deviation (i.e. "whiten" it - as in "white noise" where each frequency has equal power). Each feature is divided by its standard deviation across all observations to give it unit variance.
Parameters
obs: ndarrayEach row of the array is an observation. The columns are the features seen during each observation
# f0 f1 f2 obs = [[ 1., 1., 1.], #o0 [ 2., 2., 2.], #o1 [ 3., 3., 3.], #o2 [ 4., 4., 4.]] #o3
check_finite: bool, optionalWhether to check that the input matrices contain only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs. Default: True for eager backends and False for lazy ones.
Returns
result: ndarrayContains the values in
obsscaled by the standard deviation of each column.
Examples
import numpy as np from scipy.cluster.vq import whiten features = np.array([[1.9, 2.3, 1.7], [1.5, 2.5, 2.2], [0.8, 0.6, 1.7,]])✓
whiten(features)
✗array([[4.17944, 2.69811, 7.21249],
[3.29956, 2.93273, 9.33381],
[1.75977, 0.70386, 7.21249]])
Aliases
scipy.cluster.vq.whiten