【python】np.rint() 和 np.ceil() 和 np.linspace()

1、用法:np.rint()是根据四舍五入取整

2、用法:np.ceil()是向上取整,与四舍五入无关

>>import numpy as np
>>n = np.array([-5.6, -4.2, -2.7, 2.7, 4.3, 5.5, 8.1])
>>print(np.ceil(n))
>>print(np.rint(n))

[-5. -4. -2.  3.  5.  6.  9.]
[-6. -4. -3.  3.  4.  6.  8.]

3、用法:np.linspace(start, stop, num)

     返回:在[start, stop]区间内,选取均匀分布的num个点

​>>x = np.rint(np.linspace(64, 176, 6))
>>y = np.rint(np.linspace(64, 176, 6))
>>z = np.rint(np.linspace(64, 91, 4))
>>print(x)
>>print(y)
>>print(z)​

[  64.   86.  109.  131.  154.  176.]
[  64.   86.  109.  131.  154.  176.]
[ 64.  73.  82.  91.]

你可能感兴趣的:(Python函数)