开发者

Problems with generating Probability Distribution Function (PDF) in R

Hi I am using R to analyze data from output of my simulation. I am using hist function to generate pdf's the exact command i give is

hist(data_delay$delay,freq=F)

In my understanding the values the y axis of the chart should be less then 1, all the counts on Y-Axis should add up to 1. But unfortunately 开发者_运维技巧I am not getting random range at Y-Axis, sometimes values in 1000's.

I am attaching my sample input file. In this the Y-Axis values are in the range of 0 to 100.

Thank you for all the help you can provide.

My data is as follows http://www.mediafire.com/?twyoseg8bai0dr7


According to the hist documentation, when freq=FALSE, "the histogram has a total area of one". It does not say that the height of every bar should be less than one. The histogram created with your command and data does have a total area of 1.

> data_delay <- read.csv("PATH_TO_DATA_FILE")
> h <- hist(data_delay$delay, plot=F)
> h
$breaks
 [1] 0.000 0.005 0.010 0.015 0.020 0.025 0.030 0.035 0.040 0.045 0.050 0.055
[13] 0.060 0.065 0.070

[SNIP]

$density
 [1] 112.47892074  13.36706015   3.91231029   5.98088814  10.35413153
 [6]  11.21978640  11.80438449   6.55424396  14.14277684   2.63069140
[11]   5.53119730   1.31534570   0.69702080   0.01124227

[SNIP]

The breaks are equally spaced 0.005 apart, so we can see the total area in the histogram by doing the following.

> sum(h$density * 0.005)
[1] 1


You might prefer ?density

as in foo<-density(rnorm(1000)) ; plot(foo)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜