pydiodon.scale¶
- pydiodon.scale(A)[source]¶
Scales a matrix columnwise
- Parameters
- Aa 2D numpy array, n x p
the matrix to be scaled
- Returns
- Asa 2D numpy array
matrix A with scaled columns
- aa 1D numpy array, p values
the norm of each column of A
Notes
It is recommended to center A columnwise before scaling.
Each coordinates \(a_{ij}\) of A is replaced by \(a_{ij} / ||a_{.j}||\) where \(||a_{.j}||\) is the norm of column j: \(||a_{.j}||^2 = \sum_i a_{ij}^2\)
Example
>>> import pydiodon as dio >>> import numpy as np >>> n = 4 ; p = 3 >>> A = np.arange(n*p) >>> A.shape =(n,p) >>> Ac, m = dio.center_col(A) >>> As, s = dio.scale(Ac)
af, 21.02.19, 22.10.13