フィルターのクリア

How to define the bin size for a histogram

8 ビュー (過去 30 日間)
upinderjeet
upinderjeet 2014 年 9 月 20 日
コメント済み: upinderjeet 2014 年 9 月 20 日
Hello
I have 2 questions.
I am trying to create 100 bins for my histograms which covers actually 10000 data points. The command bincounts = histc(x,binranges), allows me to put the binranges value but I dont want to repeat (0 100 200..........10000)as the value for 'binranges'. So is there any shorter way to give that kind of argument for binranges to use that command. Once I know that, I can use bar(binranges,bincounts,'histc') to plot the histogram.
Second question, how do I normalize the area of the histogram to be 1.
Thanks

採用された回答

Guillaume
Guillaume 2014 年 9 月 20 日
There are two histogram functions in matlab. The other one, hist allows you to specify the number of bins instead of the edges.
As for normalising:
dist = hist(data, 100);
dist = dist / sum(dist);
  5 件のコメント
upinderjeet
upinderjeet 2014 年 9 月 20 日
Thanks
upinderjeet
upinderjeet 2014 年 9 月 20 日
Hi, one more question:
I am using the following code:
X=rand(10000,1);
[N,centers] = hist(X, 100);
N = N / sum(N); figure(1)
bar(centers, N); %or plot
xlim([min(centers) max(centers)]);ylim([0 1]);
Y=pdf('uniform',X,0,1);
figure(2)
plot(Y)
I am not getting the normalized area of 1. The method you told me gives me normalized x axis of the plot but I want the total area to be 1 as well. Like, If i am able to expand the histogram plot vertically(multiply by 100), I would get area of 1. But not really sure how to achieve this. Please run my code to see my problem

サインインしてコメントする。

その他の回答 (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