normalizing data and avoiding dividing by zero
While you could do this manually, Python also has a handy little function called MinMaxScaler, which will automatically apply max-min normalization to scale data between 0 and 1.

Assume we have an array of 200 values for variables s and t:

import numpy as np
import pandas as pd
from sklearn.preprocessing import MinMaxScaler

mu, sigma = 20, 10 # mean and standard deviation
s = np.random.normal(mu, sigma, 200)
t = np.random.normal(mu, sigma, 200)


Reshape your variables if necessary:

s=np.reshape(s,(-1,1))
t=np.reshape(t,(-1,1))


Now, you can see that we are forming two new variables, snew and tnew, which we are scaling using MinMaxScaler.

scaler = MinMaxScaler()
print(scaler.fit(s))
print(scaler.fit(s))
snew=scaler.transform(s)
tnew=scaler.transform(t)


Here is a sample of our new variables:

&gt;&gt;&gt; snew
array([[0.24896606],
       [0.63121206],
       [0.60448469],
       .......
       [0.49044733],
       [0.28131596],
       [0.32909155]

&gt;&gt;&gt; tnew
array([[0.91224005],
       [0.74540598],
       [0.3938718 ],
       .......
       [0.75749275],
       [0.80709325],
       [0.19440844]