Im trying to run this kind of loop (its simplified in this example) that generates and adds up random consumption´s for 1000 clients, which takes approximately 1h30h.
import numpy as np
rand_array = np.random.rand(35000)
total_consumption = np.zeros(35000)
for t in range(0,1000):
consumption = np.zeros(35000)
consumption[0] = 0.5
rand_array = np.random.rand(35000)
for i in range(1,35000):
consumption[i] = rand_array[i] * consumption[i-1]
total_consumption = total_consumption + consumption
Is there a way I can make this faster and more efficient? I tried to use list comprehension to no avail
sum()? Care withnumpy.sum()as it does not always return overflow errors if your type is too small.