Filter löschen
Filter löschen

Plotting boxplot with distributions other than normal distribution

71 Ansichten (letzte 30 Tage)
Hi,
I was wondering if it's possible to use boxplot or a similar plotting technique to plot data that are not normally distributed?
Thanks!

Akzeptierte Antwort

Adam Danz
Adam Danz am 17 Mär. 2020
Bearbeitet: Adam Danz am 17 Mär. 2020
"[is it] possible to use boxplot or a similar plotting technique to plot data that are not normally distributed? "
Yes.
Is it the best way to summarize a non-normal distribution? Probably not.
Below is a skewed distribution shown as a histogram and a boxplot. You can see the median value of the boxplot is accurate and the quartile markers (the edges of the 'box') show the skew. The outliers also indicate a skew. However, the median value doesn't indicate the expected value since the distribution isn't anywhere near normal. The histogram is much more descriptive and doesn't require knowing how to read a boxplot for the viewer to see the shape of the distribution or the expected value. But if you're more interested in the median and quartile values, a boxplot may better suit your needs.
x = pearsrnd(0,1,1,4,1000,1);
med = median(x);
clf()
s(1) = subplot(4,1,1:3);
histogram(x)
xline(med,'r-','Median', 'linewidth',2)
grid on
s(2) = subplot(4,1,4);
boxplot(x, 'Orientation','Horizontal')
grid on
linkaxes(s, 'x')
  5 Kommentare
ardeshir moeinian
ardeshir moeinian am 17 Mär. 2020
Bearbeitet: ardeshir moeinian am 17 Mär. 2020
yes you are right, the expected value would be different!
Adam Danz
Adam Danz am 17 Mär. 2020
Bearbeitet: Adam Danz am 17 Mär. 2020
Yes, and that's something the histogram shows but the boxplot does not.
If you'd like to use a boxplot for other reasons, note that you could compute the expected value from the distribution (ie, fitting, like you mentioned) and then add a marker to the boxplot where peak of the distribution is.
This demo just marks the center of the tallest bin.
% t is the output from histogram()
% t = histogram(x);
[~, maxIdx] = max(t.Values);
peakBinCenter = t.BinEdges(maxIdx+1) - t.BinWidth/2;
hold on
plot(peakBinCenter, 1, 'g*')

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by