def normalize_z_max(spectrum: Spectrum, in_place: bool = False): mu = np.mean(spectrum.y) sig = np.std(spectrum.y) if not in_place: spectrum = spectrum.copy() spectrum.y = np.array([(y - mu) / sig for y in spectrum.y]) spectrum.y /= np.max(spectrum.y) return spectrum
def normalize_z(spectrum: Spectrum, in_place: bool = False): """ Normalize by treating the spectrum as a normal distribution and finding the 'z-score' associated with each point :param spectrum: :param in_place: :return: """ mu = np.mean(spectrum.y) sig = np.std(spectrum.y) if not in_place: spectrum = spectrum.copy() spectrum.y = np.array([(y - mu) / sig for y in spectrum.y]) return spectrum