Borrar filtros
Borrar filtros

determining bin placement, histograms

5 visualizaciones (últimos 30 días)
Matlabhelp
Matlabhelp el 28 de Sept. de 2016
Comentada: Image Analyst el 25 de Ag. de 2020
Good evening
I'm using the method of determining bin placement for a histogram and was wondering if this was correct
N = 5;
edges = [0.4,0.8,1.2,1.6,2];
[N,edges,bin] = histcounts(value,'BinMethod','integers');
value = my array. I was wondering if for each edge that each value in my array will go into each corresponding bin. I wasn't sure how the " N ", or " Bin " part of the code works and need some clarification. To clarify also i'd all values at less than 0.4 to be in a bin and then every number below 0.8 to 0.4 to be in a 2nd bin and so forth
  1 comentario
Image Analyst
Image Analyst el 25 de Ag. de 2020
Original question in case he deletes it like other posts:
Good evening
I'm using the method of determining bin placement for a histogram and was wondering if this was correct
N = 5;
edges = [0.4,0.8,1.2,1.6,2];
[N,edges,bin] = histcounts(value,'BinMethod','integers');
value = my array. I was wondering if for each edge that each value in my array will go into each corresponding bin. I wasn't sure how the " N ", or " Bin " part of the code works and need some clarification. To clarify also i'd all values at less than 0.4 to be in a bin and then every number below 0.8 to 0.4 to be in a 2nd bin and so forth

Iniciar sesión para comentar.

Respuestas (1)

Steven Lord
Steven Lord el 28 de Sept. de 2016
Since you have a set of desired bin edges, I would pass those into histcounts (or histogram if you want to see the results graphically) as the second input and remove the 'BinMethod' parameter name/value pair.
[N, edgesOut, bin] = histcounts(value, edges);
You should see that edgesOut is the same as edges.
If you want a bin before the first value in edges, add -Inf at the start of your edges vector.
[N, edgesOut, bin] = histcounts(value, [-Inf, edges]);
Then the first bin will contain those elements in value whose value is in the range [-Inf, 0.4). Similarly, if you want a bin after the last edge, add Inf at the end to catch values in the range [2, Inf].
  2 comentarios
Matlabhelp
Matlabhelp el 28 de Sept. de 2016
Do i have to specify 'N' or 'Bin'?, or are those already accounted for because i have already stated what they are equal to.
Steven Lord
Steven Lord el 28 de Sept. de 2016
If you specify the edges explicitly, you don't need to specify the number of bins as an input. In this case histcounts and histogram compute the number of bins as one fewer than the number of edges.
If you specify the edges explicitly, you don't need to specify 'BinMethod' as an input either. The 'BinMethod' parameter allows you to specify what algorithm histcounts should use to calculate where the bin edges should be. Since you explicitly told histcounts where the bin edges should be, it shouldn't try to calculate new edges but should use what you told it.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Distribution Plots 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