📜  Python| numpy matrix.ptp()

📅  最后修改于: 2022-05-13 01:55:30.780000             🧑  作者: Mango

Python| numpy matrix.ptp()

Numpy matrix.ptp()方法的帮助下,我们可以从给定矩阵中获得沿轴的(最大-最小) peek-to-peek值。

示例 #1:
在这个例子中,我们可以看到我们能够在方法matrix.ptp()的帮助下从给定矩阵中获取 peek-to-peek 值。

# import the important module in python
import numpy as np
          
# make matrix with numpy
gfg = np.matrix('[64, 1; 12, 3]')
          
# applying matrix.ptp() method
geeks = gfg.ptp(1)
    
print(geeks)
输出:
[[63]
 [ 9]]

示例 #2:

# import the important module in python
import numpy as np
          
# make a matrix with numpy
gfg = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, -9]')
          
# applying matrix.ptp() method
geeks = gfg.ptp(0)
    
print(geeks)
输出:
[[ 6  6 15]]