I have the following task where I am given an audio signal: Center the signal (subtract the mean value) and normalize to a dynamic range of -1 to 1 (divide be maximum of the absolute value).
If I understood right this means:
- Centering - mean value will be set to 0;
- Normalizing - signal will be set to a range (-1, 1).
After some research I wrote a simple script in Python to test centralization and normalization.
def calc_mean(data):
sum = 0
for value in data:
sum = sum + value
return sum / len(data)
data = [-2, -2.4, -5, -10, -6.4, -0.4, 1, 1.1, 12, 2.55, 6]
mean = calc_mean(data)
maxabs = abs(max(data))
data_new = []
for value in data:
data_new.append((value - mean) / maxabs)
print(calc_mean(data_new))
print(min(data_new), max(data_new))
Output:
-3.027880976250427e-17
-0.806439393939394 1.0268939393939394
Is this the right way to centralize and normalize signal(data series)?