Azzera filtri
Azzera filtri

Find the two most commonly occurring values in a multimodal distribution of numbers.

2 visualizzazioni (ultimi 30 giorni)
My data looks like this, when plotted:
(x axis is just index number)
looking at this, I know the values I'm looking for are ~0 and ~-3. I need Matlab to find this automatically.
There is a distribution-like clustering around these values (so the actual values aren't all the same, so using something like mode doesn't help, among other reasons).
Here is a zoomed in picture of the above for clarity on what the "distribution" looks like.
I tried using fitdist but it will not work with negative numbers. And sometimes my numbers are symmetric around zero, so I dont want to just take the absolute value.
It seems like it should be a simple thing, but I'm stumped.

Risposte (1)

Jeff Miller
Jeff Miller il 28 Feb 2024
It would be more informative to see a histogram of your y values since they aren't related to x per se. If that histogram looks approximately like a mixture of three normals, then you could use
GMModel1 = fitgmdist(y,3);
The output will give you "component proportions" for the three components, and you could then use the mu's of the two components with the highest proportions, if those mu's fit your idea of the "most common" scores (given the slight variations among similar scores).

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by