如何使用给定数量的数据点生成两个值之间的指数曲线

How to generate an exponential curve between two values with a given amount of data points

我正在尝试实现如下函数,但我确实缺乏数学技能,任何帮助将不胜感激。

该函数应采用一定数量的数据点 x 和 return 大小为 x 的数组,其中包含从 0 到 100 的指数递增值(例如)。理想情况下,它还应该接受一个 lambda 值来修改曲线。

function exponentialCurve(x, max=100, lambda=4) {
  // returns an array of size x where each entry represents a point on an exponential curve between 0 and max
}

这是为了对音频 PCM 数据应用指数衰减。 再一次,任何能帮助我指明正确方向的东西都会很棒,感谢阅读。

这是您要查找的内容吗(其中 1 <= lambda <=10)?

function exponentialCurve(x, max=100, lambda=4) {
    // returns an array of size x where each entry represents a point on an exponential curve between 0 and max
    const base = Math.log(x) / Math.log(lambda);
    const points = Array(x).fill(max);
    return points.map((point, n) => point / Math.pow(base, n));
}