If you need to calculate decaying function but you need to do it step by step then use the function below.
import numpy as np #one step of the decay def decay(val, rate): return val * np.exp(-rate) rate = 0.5 val = 10 for i in range(10) : print(val) val = decay(val, rate)
Output: 10 6.065306597126334 3.678794411714423 2.231301601484298 1.3533528323661268 0.8208499862389879 0.4978706836786394 0.30197383422318497 0.1831563888873418 0.11108996538242305
more decay Functions :
def fade(val,lam=0.05): return np.exp(-val * lam) #exp decay: given max value and rate def decay_max(x, maxx, rate) : return maxx * (( 1 - rate ) ** x) #exp decay : given min&max value and how many steps to go from min -> max def mm_decay(x, minn, maxx, steps) : rate = (maxx ** float(1/float(steps)) ) - 1.0 val = decay_max(x,maxx,rate) if val < minn : return 1 return val