Normalization pdf histogram and cdf

77 ビュー (過去 30 日間)
Farshad Daraei Ghadikolaei
Farshad Daraei Ghadikolaei 2020 年 5 月 2 日
コメント済み: Steven Lord 2022 年 6 月 28 日
Hi, I am using this code in MATLAB:
histogram(my data,'Normalization','pdf');
after plotting the pdf histogram, the y axis is in a range between 0 to 100. But I need to have the y axis in a range between 0 to 1, because when I plot: (my data, 'Normalization','cdf') the y axis is in range 0 to 1. Please help me to have both "pdf" and "cdf" in a same y axis scale (0 to 1) in one graph. Thank you.
  1 件のコメント
Thi Lan Anh DINH
Thi Lan Anh DINH 2022 年 6 月 28 日
Using 'probability' instead of 'pdf', so that your y-axis will be from 0 to 1.
histogram(my data,'Normalization','probability');

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

回答 (2 件)

Walter Roberson
Walter Roberson 2020 年 5 月 2 日
You could use ylim() to simply prevent the peak from being drawn.
Or you could increase the bar widths, such as by decreasing the number of bars you ask for.
  5 件のコメント
Jeff Miller
Jeff Miller 2020 年 5 月 3 日
Yes, that is possible. Look at the command 'yyaxis' or (if you have an older version of MATLAB) 'plotyy'.
Farshad Daraei Ghadikolaei
Farshad Daraei Ghadikolaei 2020 年 5 月 3 日
Thank you Jeff. I will try.

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


Farshad Daraei Ghadikolaei
Farshad Daraei Ghadikolaei 2020 年 5 月 6 日
Hi Walter, Could you please let me know the difference between 'pdf' and 'probability' plots?
  3 件のコメント
Farshad Daraei Ghadikolaei
Farshad Daraei Ghadikolaei 2020 年 5 月 8 日
Thanks.
Steven Lord
Steven Lord 2022 年 6 月 28 日
If you look at the description of the Name-Value argument 'Normalization' on the histogram documentation page, the table in that section lists how the bin values are computed.
For probability Normalization, the bin values are the bin counts divided by the number of elements in the input data and so they must all be less than or equal to 1.
For pdf Normalization, the bin values are the probability values (= bin counts divided by number of elements) divided by the bin width. If you have bins of width less than 1 the pdf bin values will be greater than the probability bin values.

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

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by