相关疑难解决方法(0)

对数间隔的整数

假设我有一个10,000磅的矢量,我想采取一个只有100个对数间隔点的切片.我想要一个函数给我索引的整数值.这是一个简单的解决方案,只需使用+ logspace,然后摆脱重复.

def genLogSpace( array_size, num ):
    lspace = around(logspace(0,log10(array_size),num)).astype(uint64)
    return array(sorted(set(lspace.tolist())))-1

ls=genLogspace(1e4,100)

print ls.size
>>84
print ls
array([   0,    1,    2,    3,    4,    5,    6,    7,    8,    9,   10,
         11,   13,   14,   15,   17,   19,   21,   23,   25,   27,   30,
         33,   37,   40,   44,   49,   54,   59,   65,   71,   78,   86,
         94,  104,  114,  125,  137,  151,  166,  182,  200,  220,  241,
        265,  291,  319,  350,  384,  422,  463,  508,  558,  613,  672,
        738,  810,  889,  976, 1071, 1176, …
Run Code Online (Sandbox Code Playgroud)

python numpy resampling

18
推荐指数
1
解决办法
1万
查看次数

标签 统计

numpy ×1

python ×1

resampling ×1