【问题标题】:running exponential decay with addition?运行指数衰减加法?
【发布时间】:2020-08-09 15:18:35
【问题描述】:

指数衰减的公式是:

 np.exp(-(t/n))

其中 t 是时间步长,n 是控制衰减速度的系数。 我正在寻找的是 running-函数,我在其中手动计算每一步的值,以及在衰减期间添加值的能力。

我该怎么做?

我还找到了另一个公式:(1-percent)^t


 def decay(val, rate): return val * np.exp(-rate)

In [84]: decay(1,1/10.)
Out[84]: 0.905

In [85]: decay(0.905,1/10.)
Out[85]: 0.819

In [86]: decay(0.819,1/10.)
Out[86]: 0.741

In [88]: np.exp(-1/10.)
Out[88]: 0.905

In [89]: np.exp(-2/10.)
Out[89]: 0.819

In [90]: np.exp(-3/10.)
Out[90]: 0.741

【问题讨论】:

  • 我投票结束这个问题,因为这是一道数学题。
  • 这是一个正在运行的 exp 衰减 .. 即程序员问题 ... 即将数学公式转换为算法!!!
  • 你为什么不做一个循环并添加decay函数返回?如果您正在寻找总和的明确公式,那么是的,这是一个数学问题。

标签: python exponential cumulative-sum decrement


【解决方案1】:

我可以建议在每个时间步t使用一个数组来评估吗?您需要编辑函数以包含衰减常数 n

def decay(t, A, n):
    return A*np.exp(-t/n)

t = np.linspace(0, 10, 256)

initial = 1
rate = 10

value = decay(t, initial, rate)

value 将是每个 t 处衰减函数值的数组。

【讨论】:

  • 谢谢...不,我知道我需要什么...我不需要跟踪,只需保留一个更新和衰减的值,但可以在中途更改 :)
猜你喜欢
  • 2015-06-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多