[英]How to calculate mean of each bin after using `numpy.digitize` to split up a NumPy array?
[英]How to find the elements of each bin after using the histcount function
我正在使用histcount方法將數組數據分類到單獨的容器中。 這是我使用的簡單代碼。
[N,edges] = histcounts(score,5)
其中“分數”是整數數組。 除了比較方法以外,如何顯示每個面元的所有元素。 MATLAB中有可用的內置方法嗎?
histcounts
的第三次輸出histcounts
給出:
>> data = [0.81470.9058 0.12700.91340.6324 .09750.2785 0.5469];
>> [N,edges,bin] = histcounts(data,5)
N =
2 1 1 1 3
edges =
0 0.1900 0.3800 0.5700 0.7600 0.9500
bin =
5 5 1 5 4 1 2 3
[N,edges] = histcounts(score,n)
從最低到最高的[N,edges] = histcounts(score,n)
訂單得分,並將得分分為n = 5個倉位。 N
是一個向量,指示每個容器中有多少個對象,並且邊沿定義每個容器的端點。 因此,如果要退回第一個倉中的內容,請訂購分數,然后使用N(1)
第一個倉中的對象數量。
要排序分數,請輸入sorted_score = sort(score)
。
要查看此元素的前N(1)個元素,請輸入sorted_score(1:N(1))
。
輸出sorted_score(N(i-1)+1:N(i))
( N(0) = 0
)是score的子向量,根據要求顯示bin i
的score的所有元素。
編輯:澄清輸出。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.