Is it possible to create a histogram with fractional entries for each bin?
Show older comments
Thank you for looking at my question! I have included a brief introduction below; any suggestions or comments would be greatly appreciated!
Traditional histograms are generated using an array (e.g. sample_array = [1,1,1,2,2,3,3,3,3,4]) and the histogram is generated using h = histogram(sample_array,nbins);. In this example, with nbins = 4, I would have a simple histogram of column height associated with the number of times a particular value is observed in the sample array.
However, in my work I have come upon the need to instead use an array in place of a single value. For example:
sample_array = [1,1,[1,2],2,2,3,[2,3,4,5],3,4];
I am aware this is not an array. For convenience I am instead using a cell to contain the data:
sample_cell = {1,1,[1,2],2,2,3,[2,3,4,5],3,4};
What I need to do is generate the resulting histogram of sample_cell where I give EACH ENTRY of the cell EQUAL WEIGHT. The corresponding weights would be as follows:
sample_weight = {1,1,[1/2,1/2],1,1,1,[1/4,1/4,1/4,1/4],1,1};
From this, the resulting histogram would have the following counts in the bins for 1 thru 4:
Bin: Count
1: 2.5
2: 2.75
3: 2.25
4: 1.25
I am looking for a way to generate this resulting histogram which does not include using the least common multiple of the sizes of each entry. (I have a temporary solution to the problem including this quantity, however, I am unable to scale it up properly as I am dealing with very large prime numbers which result in LCM > 10^9.)
Again, any help or suggestions that you might have would be greatly appreciated!
Accepted Answer
More Answers (0)
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!