Borrar filtros
Borrar filtros

binning histogram and obtaining the proportions

2 visualizaciones (últimos 30 días)
jenka
jenka el 4 de Mayo de 2017
Editada: dpb el 4 de Mayo de 2017
Dear all, I have a quick question. I have histogram and now suppose a new observation comes in and I would like to know which bin in my histogram does it belong to. I then would like to return the proportion of that particular bin. The bin proportion corresponds to the number of observations falling into that bin divided by the total number. Thank you all in advance.

Respuestas (1)

dpb
dpb el 4 de Mayo de 2017
Editada: dpb el 4 de Mayo de 2017
Simplest is probably to just return the bin of the observation via histcounts or histc, whichever you're using with the same bin edges vector as created the original.
[~,~,bin]=histcounts(newX,oldEdgesVector);
Or, it's a lookup using the edges vector
bin=fix(interp1(oldEdgesVector,1:length(oldEdgesVector),newX));
Note interp1 will return interpolated value; return integer portion to get bin. 'nearest' will round, so don't want that. 'previous' may yield same result; I didn't test; I'd probably use the former to be sure had same internal logic w/o worrying about details.

Categorías

Más información sobre Histograms 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