为什么我的钟形曲线是平的

时间:2023-01-21 14:57:08

I have a data coming from temperature sensor. I wanted to plot histogram with a normal distribution overlay on top. I'd expect the overlay to be not flat, but it is a flat line for some reason. Why?

我有来自温度传感器的数据。我想用正态分布叠加在上面绘制直方图。我希望覆盖层不是平的,但出于某种原因它是一条平线。为什么?

I have an idea that this is because the data is somewhat discrete. Sensor registeres temperature approximately, so it rounds up to 0.2 C. Naturally the data domain has spaces. My data has a few thousands points, but when I do unique(temperature$VALUE) - I receive 70 points. Could this be a problem? If yes, how can I fix my R code?

我有个想法,这是因为数据是离散的。传感器的温度大约为0.2摄氏度,因此数据域自然有空间。我的数据有几千个点,但是当我做唯一的(温度$VALUE) -我得到70个点。这会是个问题吗?如果是,我如何修正我的R码?

ggplot(temperature, aes(VALUE)) + geom_histogram(binwidth = 0.05) + 
  stat_function(geom="line", fun=dnorm,   lwd = 1, colour="red", args=list(mean = mean(temperature$VALUE), sd = sd(temperature$VALUE)))

为什么我的钟形曲线是平的

I'm not that good in stat, so sorry if I'm doing something very weird, please explain if that's true.

我的统计能力不是很好,如果我做了一些很奇怪的事情,请解释一下是不是真的。

1 个解决方案

#1


0  

The normal density function has value range of [0,1]. And your Y axis is actually a count of frequency (more than 200).

正态密度函数的取值范围为[0,1]。Y轴是频率的计数(大于200)

There is no method to have 2 Y Axis on the same ggplot graph.

没有一种方法可以在同一个格线图上有两个Y轴。

But you can try to convert the frequency to proportions.

但是你可以把频率转换成比例。

#1


0  

The normal density function has value range of [0,1]. And your Y axis is actually a count of frequency (more than 200).

正态密度函数的取值范围为[0,1]。Y轴是频率的计数(大于200)

There is no method to have 2 Y Axis on the same ggplot graph.

没有一种方法可以在同一个格线图上有两个Y轴。

But you can try to convert the frequency to proportions.

但是你可以把频率转换成比例。