本文介绍了R中的正态分布图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 plot 命令在 r 中绘制正态分布:

plot(x, dnorm(x, mean, sd)),

使用我的平均值和标准差值.

但是,有了这些值,y 轴上的数字大于 1.既然我想要一个概率密度函数,这正常吗?否则我的值是合理的,例如在置信区间.此外,函数的形状是合理的.轴是唯一的问题.

解决方案

这很正常,我猜你是在混淆概念.

对于离散事件,您可以为每个结果分配一个概率,我们称之为probability mass.这是一个概率,因此必须在 [0, 1] 范围内.

对于连续结果,我们可以离散将空间分成一组bins,每个bins 包含一个变量区间.然后定义概率密度,即binprobability mass除以那个bin区间.>

这就是为什么您可以使 probability Densities 大于 1:在小范围内的一些大概率质量,例如物理学中的密度 = 质量/体积.

您可以在 https://stats.stackexchange.com/ 获得更好的答案/解释,祝您好运!

I am trying to plot a normal distribution in r using the plot command:

plot(x, dnorm(x, mean, sd)),

using my values for mean and sd.

However, with these values, the numbers on the y-axis are greater than 1. Since I want a probability density function, is this normal? My values are reasonable otherwise, for example in confidence intervals. Also, the function's shape is reasonable. The axis is the only issue.

解决方案

This is normal, you're mixing concepts i guess.

For discrete events you can assign a probability for each outcome, which we call probability mass. This is a probability, so must be in the range [0, 1].

For continuous outcomes we can discretize the space into a set of bins, each one holding a interval of your variable. Then you define probability density, which is the probability mass of a bin divided by that bin interval.

That's why you can get probability densities greater than 1: some big mass of probability inside a small range, like density = mass/volume in physics.

You can get a better answer/explanation at https://stats.stackexchange.com/, good luck!

这篇关于R中的正态分布图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 22:39