R density plot y axis larger than 1

故事扮演 提交于 2019-12-12 09:23:19

问题


I want a density plot, and here is the code:

d = as.matrix(read.csv(file = '1.csv'))
plot(density(d))

my data is a list of number. What I don't understand is that the value of y axis large than 1 I think there is something wrong and search the internet, but i can't find any resource, Can you guys help me? enter image description here here is the data: link:http://pan.baidu.com/s/1hsE8Ony password:7a4z


回答1:


There is nothing wrong with the density being greater than 1 at some points. The area under the curve must be 1, but at specific points the density can be greater than 1. For example,

dnorm(0,0, 0.1)
[1] 3.989423

See this Cross Validated post

Edit:
I think that the dnorm part above could be amplified a little.

For a Gaussian distribution, with mean μ and standard deviation σ approximately 99.73% of the area under the density curve lies between μ-3σ and μ+3σ. The example above used μ=0 and σ=0.1 so the area under the curve between -0.3 and 0.3 should be 0.9973. The width of the curve here is 0.6. Compare this with a rectangle of equal area (0.9973) and the same base (0.6).

If the area of the rectangle is 0.9973 and the base is 0.6, the height must be 0.9973/0.6 = 1.6621, i.e. the average height of the curve must be 1.6621. Clearly there must be some points with height greater than 1.



来源:https://stackoverflow.com/questions/42661973/r-density-plot-y-axis-larger-than-1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!