import numpy as np
t_full = np.linspace(0, 0.01, 2 ** 12, endpoint=False)
thetas = np.multiply.outer(2 * np.pi * t_full, w)
thetas += 2 * pi * np.random.random(thetas.shape)
signal = np.cos(thetas)
signal *= dataCOS
signal = signal.sum(-1)
Efficient calculation of cosine in python