如何在 numpy 数组中沿特定轴获取掩码下的标准偏差?
data = array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19],
[20, 21, 22, 23, 24]])
M = array([[0, 1, 0, 0, 0],
[1, 1, 1, 1, 1],
[1, 1, 0, 1, 1],
[0, 0, 1, 0, 0],
[0, 0, 0, 0, 0]])
结果数组应为:
masked_std = std( data, axis=0, mask=M )
[ std([5,10]), std([1,6,11]), std([7,17]), std([8,13], std([9,14]) ]