我在使用linspace函数时遇到了一些问题。我想生成一个数字数组,例如:
[0.000001, 0.00001, 0.0001 , 0.001 ,0 .01 , 0.1]
所以我尝试了下面的代码:
alphas = np.linspace(0.0000001,10,num=11)
print(alphas)
获得了结果:
[ 1.00000000e-07 1.00000009e+00 2.00000008e+00 3.00000007e+00
4.00000006e+00 5.00000005e+00 6.00000004e+00 7.00000003e+00
8.00000002e+00 9.00000001e+00 1.00000000e+01]
我原本认为这是显示和格式的问题,但在尝试后发现不是这个问题。
if(alphas[0]>1):
print("yes the first number is greater than 1")
if(alphas[1]>1):
print("yes the second number is greater than 1")
第二个数字确实大于1,那么我的问题是什么?既然linspace应该“在指定的区间内返回均匀间隔的数字”。