Some questions with histograms
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Greetings all,
I have 3 questions about the attached histogram.
1.) When I use MATLAB's mode command in my code, it does not match the output for this histogram. What I mean by that is, since the mode is defined as being the most common element of an array, according to that histogram, it should be in the 70-80 bin range, not 1.0329 as per MATLAB's mode output.
Code for that is (just in case):
mode_Sigma1=mode(OutputMatrixValid(1:numtrue,48));
where (OutputMatrixValid(1:numtrue,48)) is all of the Sigma1 values. Did I do something wrong or is there a bug in MATLAB's mode command?
2.) Is there anyway to "shade" histograms by confidence interval/percentile (did a web search and no luck)? For instance, the black lines represent the 95% CI, blue lines are the 25%/75%, and the green lines are the 68% (i.e., +/- the standard deviation). By shading, I mean shading the bars of the histogram that are in these CI ranges. Is there any way to do that?
3.) Is there any way to create a "stacked" histogram in MATLAB (did a web search and again no luck)? These Sigma1 values were generated by the following function call and code:
function [sigma1 sigma2] = CalculateSigma1and2(sigmaa, sigmab, ra0, rb0, ra1, rb1)
n = 1;
for i = 1:length(sigmaa)
for j = 1:length(sigmab)
sigma1(n) = (sigmaa(i)*rb1(j) -sigmab(j)*ra1(i))/(ra0(i)*rb1(j) - rb0(j)*ra1(i));
sigma2(n) = (sigmaa(i)*(rb0(j)-rb1(j)) - sigmab(j)*(ra0(i)-ra1(i)))/(ra1(i)*rb0(j) - rb1(j)*ra0(i));
n = n + 1;
end
end
end
So there are multiple inputs to calculate Sigma1, but luckily the "sigmaa" and "sigmab" are values based on location pairs between two instruments that I have in an array, like so:
sigma_a = [EM31West; EM31East; GSSIWest; GSSIEast];
So, back to my original question (apologies if too much detail was presented, but I'd rather go with too much than not enough), is there a way to make a stacked histogram such that, the bins have one color for the Sigma1's generated from EM31West vs. EM31East, and another color for GSSIWest vs. EM31East, etc. Again, this is based on location pairs to calculate Sigma1 in the first place.
Thanks! Jesse
2 Kommentare
Geoff Hayes
am 26 Nov. 2015
Jesse - there is no attached histogram. Once you have chosen the file, you must press the Attach File button.
Also, what can you tell us about OutputMatrixValid(1:numtrue,48)? What are some of the values, what is the minimum and what is the maximum? And also please provide the code that you use to generate the histogram that presumably makes use of OutputMatrixValid(1:numtrue,48)).
Akzeptierte Antwort
Thorsten
am 26 Nov. 2015
Bearbeitet: Thorsten
am 26 Nov. 2015
The histogram counts values in a range, the mode counts occurrences of numbers. So for example, if X = [1 1 1 11 11 12 13 14 15], the histogram peaks for the bin 11-20 (provided you have bins 1-10, 11-20), but the mode is 1. That's fine.
3 Kommentare
Thorsten
am 26 Nov. 2015
Bearbeitet: Thorsten
am 26 Nov. 2015
help mode
tells you
When there are multiple values occurring equally frequently, mode
returns the smallest of those values. For complex inputs, this is taken
to be the first value in a sorted list of values.
For 2, you could get the values and centers and then draw your own histogram using bars of appropriate color. For example, to color them, you can use
X = randn(1,1000);
[h c] = hist(X, 20);
d = diff(c); barwidth = d(1);
col = [0.2 0.2 1; 0.4 0.4 1; 0.6 0.6 1];
colind = abs(fix(c)) + 1;
colind(colind >3) = 3;
for i = 1:numel(h)
bar(c(i), h(i), barwidth, 'FaceColor',col(colind(i), :));
if i == 1, hold on, end
end
For 3, I do not know what you're looking for. Maybe you can write your own routine based on bar( ... 'stacked').
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!