I need to normalize a list of values to fit in a probability distribution, i.e. between 0.0 and 1.0.
I understand how to normalize, but was curious if Pytho
If you consider using numpy, you can get a faster solution.
import random, time
import numpy as np
a = random.sample(range(1, 20000), 10000)
since = time.time(); b = [i/sum(a) for i in a]; print(time.time()-since)
# 0.7956490516662598
since = time.time(); c=np.array(a);d=c/sum(a); print(time.time()-since)
# 0.001413106918334961