calculate the mode with tolerance

3 visualizaciones (últimos 30 días)
Luca cadalo
Luca cadalo el 3 de Mzo. de 2017
Comentada: Sai Sunku el 20 de Mzo. de 2020
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

Respuestas (1)

Jan
Jan el 3 de Mzo. de 2017
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 comentario
Sai Sunku
Sai Sunku el 20 de Mzo. de 2020
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by