Cumulative histogram with bin being values greater than or equal.

3 ビュー (過去 30 日間)
Edward Chen
Edward Chen 2021 年 12 月 19 日
回答済み: Image Analyst 2021 年 12 月 19 日
I'm trying to plot a dose volume histogram and I know that I can use histogram(X, 'Normalization', 'cdf') in order to plot a cumulative distributive histogram where each bin is all values less than or equal to the bin value. However, I would like to have a histogram where each bin is all values greater than or equal to the bin value. Does anyone know of a simple way to accomplish that in MATLAB?

採用された回答

Image Analyst
Image Analyst 2021 年 12 月 19 日
Do you mean like this:
data = randn(100000, 1);
[counts, edges] = histcounts(data)
counts = 1×88
1 0 0 1 0 1 3 0 1 4 5 13 25 15 29 41 46 74 91 106 162 188 264 307 418 510 604 733 818 1043
edges = 1×89
-4.6000 -4.5000 -4.4000 -4.3000 -4.2000 -4.1000 -4.0000 -3.9000 -3.8000 -3.7000 -3.6000 -3.5000 -3.4000 -3.3000 -3.2000 -3.1000 -3.0000 -2.9000 -2.8000 -2.7000 -2.6000 -2.5000 -2.4000 -2.3000 -2.2000 -2.1000 -2.0000 -1.9000 -1.8000 -1.7000
subplot(3, 1, 1);
bar(edges(1:end-1), counts)
grid on;
xlabel('Value')
ylabel('Counts')
title('Histogram')
% Compute cdf
cdf = rescale(cumsum(counts), 0, 100);
subplot(3, 1, 2);
bar(edges(1:end-1), cdf);
grid on;
xlabel('Value')
ylabel('Percent')
title('CDF')
% where each bin is all values greater than or equal to the bin value.
subplot(3, 1, 3);
bar(edges(1:end-1), 100-cdf); % or fliplr(cdf)
grid on;
xlabel('Value')
ylabel('Percent')
title('CDF')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by