繁体   English   中英

Python:根据阈值计算矩阵值

[英]Python: count the matrix values according to the threshold

请帮帮我)我有一个numpy数组160x160我需要计算的是值在a和b之间的索引数量。 我试过的:A-我的矩阵

for i in A:
   for j in A[i]:
      if A[i,j] < 0.1 and A[i,j]> 0:
          m=collections.Counter(don't know what to write here)

谢谢!

这是评论的示例扩展

arr为随机数组

In [33]: arr = np.random.rand(160,160)

获取>0 & <0.1的元素数

In [34]: ((arr>0) & (arr<0.1)).sum()
Out[34]: 2649

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM