Renormalize Spectra to Unit L2 (Euclidean) Norm
Source:R/l2_normalize_spectra.R
l2.normalize.spectra.RdAutoSpectral's stored reference spectra and spectral variants are L-infinity normalized (each spectrum's peak detector fixed to exactly 1.0), the convention used throughout unmixing. That convention implicitly asserts zero measurement variance at whichever detector happens to be the peak, pushing all of a spectrum's real variability into its off-peak channels and biasing any distance- or variability- based comparison built on top of it. Because renormalization is just a positive per-row rescaling, this function can be applied directly to already L-infinity-normalized spectra (or the raw unnormalized measurements) to obtain the L2-normalized equivalent, without needing access to the original unnormalized data.
Value
A numeric matrix of the same dimensions and dimnames as
spectra, with every row divided by its own Euclidean norm. Rows
with a (near-)zero norm are returned unchanged rather than divided
by ~0. Attributes other than dim/dimnames on the input (e.g.
noise.floor, spillover.spread) are not preserved.