change histogram to PDF

29 ビュー (過去 30 日間)
Mehri Mehrnia
Mehri Mehrnia 2022 年 6 月 28 日
回答済み: KSSV 2022 年 6 月 28 日
I have attached a histogram which is attached. This histogram is computed step by step based on milions of samples.
If I don't compute it step-wise, Matlab gives "out of memory" error!
N_bins=100;
epsai= very long cell in which each array has millions of samples
cells_max= max of all samples(#millions)
cells_min= min of all samples(#millions)
bin_width=double(cells_max-cells_min)/N_bins;
edge_epsai=double(cells_min):bin_width:double(cells_max);
N_freq=zeros(1,N_bins);
for i=1:length(epsai)-1
[N_freq_tmp,~]=histcounts(double(epsai{1,i}),edge_epsai);
%save frequency
N_freq=N_freq_tmp+N_freq;
end
result till here is attached, then I want to change to PDF as follows but the result is weird!I get lots of zero and few numbers in beginning anf ending pints of intterval!
[S_y_axis, h3,~]=histcounts(N_freq,edge_epsai,'Normalization','pdf');

回答 (1 件)

KSSV
KSSV 2022 年 6 月 28 日
x = randn(10000,1) ;
histogram(x)
pd = fitdist(x,'kernel');
x_values = min(x):0.01:max(x) ;
y_values = pdf(pd,x_values);
plot(x_values,y_values)

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by