calculate the mode with tolerance

조회 수: 3 (최근 30일)
Luca cadalo
Luca cadalo 2017년 3월 3일
댓글: Sai Sunku 2020년 3월 20일
I have a matrix A= [ 2 3 2.1 ; 8.1 3.3 2.05 ; 3.01 4.9 2.09] and I want to get the mode with a tolerance of 0.1 there is any way to get this??? to work in matlab with mode (the value most repeated) and tolerance thanks

답변 (1개)

Jan
Jan 2017년 3월 3일
The question is not trivial. What do you expect as result for:
x = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6]
?
You can round the values:
AA = round(A, 1)
and apply mode() afterwards, but this must not be necessarily, what you want.
  댓글 수: 1
Sai Sunku
Sai Sunku 2020년 3월 20일
One can bin the data with the required tolerance and return the center of the bin with the highest frequency. I'm not particular about the tolerance, so I'm doing it as follows:
[N, edges] = histcounts(data);
[~, idx] = max(N); mode = (edges(idx) + edges(idx + 1))/2;
It would be nice if there was a built-in function for this.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by