How do I show relative frequency on histogram?

23 ビュー (過去 30 日間)
JK
JK 2014 年 9 月 8 日
回答済み: Star Strider 2014 年 9 月 8 日
Okay, I am supposed to make 1000 random values between 1 to 10 and plot them on the histogram to show the relative frequency.
Also my nbins must be 50
I have..
data=rand(10.*rand(1000,1)+1) hist(data,50)
It puts data on the histogram, but how do I show the relative frequency?

採用された回答

Star Strider
Star Strider 2014 年 9 月 8 日
The relative frequency is the absolute frequency normalised by the total number of events. In your particular situation, you would get the relative frequency for each bin by dividing the empirical frequencies in each of your bins by 1000.

その他の回答 (1 件)

Ben11
Ben11 2014 年 9 月 8 日
The relative frequency is supposed to show up on the y-axis...
what about this:
clear all
data= 10*rand(1,1000);
hist(data,50);
  2 件のコメント
JK
JK 2014 年 9 月 8 日
Yea I got something like that too, but I think it just shows how many times it created on the y axis
I am trying to show something like percentage. For example, if matlab created 200 of 1s, out of 1000, then it should show 0.20 on y axis and 1.0 on x axis.
Ben11
Ben11 2014 年 9 月 8 日
oh ok I see what you mean; I got the relative frequency and relative count confused my bad.

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

カテゴリ

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