如果你認爲numpy是其中的一個標準,那麼你可以使用numpy.logspace,因爲這正是它應該做的......(注意:100 = 10^2,1000000000 = 10^9 )
for n in numpy.logspace(2,9,num=9-2, endpoint=False):
test(n)
例2(注:100 = 10^2,十億= 10^9,想去在步驟10倍,它是9-2 + 1個點...):
In[14]: np.logspace(2,9,num=9-2+1,base=10,dtype='int')
Out[14]:
array([ 100, 1000, 10000, 100000, 1000000,
10000000, 100000000, 1000000000])
示例3:
In[10]: np.logspace(2,9,dtype='int')
Out[10]:
array([ 100, 138, 193, 268, 372,
517, 719, 1000, 1389, 1930,
2682, 3727, 5179, 7196, 10000,
13894, 19306, 26826, 37275, 51794,
71968, 100000, 138949, 193069, 268269,
372759, 517947, 719685, 1000000, 1389495,
1930697, 2682695, 3727593, 5179474, 7196856,
10000000, 13894954, 19306977, 26826957, 37275937,
51794746, 71968567, 100000000, 138949549, 193069772,
268269579, 372759372, 517947467, 719685673, 1000000000])
對您的情況,我們使用endpoint=False
,因爲您不想包含端點...(例如, np.logspace(2,9,num=9-2, endpoint=False)
)
你已經得到了答案,但我可以問爲什麼? – 2012-07-12 01:39:48
要查看我在Python性能提示上發表的演講的搜索列表和詞典的區別。 – Martlark 2012-07-20 09:54:30