“向后”np.geomspace,因此随着对数函数变得更高,会出现更高的密度

Ben*_*ick 2 python geometry numpy logarithm computational-geometry

我需要在 0.5 到 1 的对数空间中生成数字。

这段代码实现了:

IN: np.geomspace(.5, 1, num=10) OUT: [0.5, 0.540029869446153, 0.5832645197880583, 0.6299605249474366, 0.6803950000871885, 0.7348672461377994, 0.7937005259840997, 0.8572439828530728, 0.9258747122872905, 1.0]

然而,较小的增量接近 0.5。我希望它们接近 1(因此,向后看,我只是不完全确定正确的术语是什么)。

我已经尝试过了np.geomspace(1, .5, num=10),但它只是以相反的顺序给了我相同的输出。

FBr*_*esi 6

IIUC 你可以这样做:

import numpy as np

1.5 - np.geomspace(1, .5, num=10)
array([0.5       , 0.57412529, 0.64275602, 0.70629947, 0.76513275,
       0.819605  , 0.87003948, 0.91673548, 0.95997013, 1.        ])
Run Code Online (Sandbox Code Playgroud)