Possible Duplicate:
Making a standard normal distribution in R可能的重复:用R做一个标准正态分布
Using R, draw a standard normal distribution. Label the mean and 3 standard deviations above and below the (10) mean. Include an informative title and labels on the x and y axes.
用R,画一个标准正态分布。标上均值和3个标准差在(10)均值之上和之下。在x轴和y轴上包含内容丰富的标题和标签。
This is a homework problem. I'm not sure how to get going with the code. How should I get started?
这是一个家庭作业问题。我不知道该怎么处理这些代码。我该如何开始呢?
3 个解决方案
#1
13
I am pretty sure this is a duplicate. Anyway, have a look at the following piece of code
我很确定这是复制品。无论如何,请看下面这段代码
x <- seq(5, 15, length=1000)
y <- dnorm(x, mean=10, sd=3)
plot(x, y, type="l", lwd=1)
I'm sure you can work the rest out yourself, for the title you might want to look for something called main=
and y-axis
labels are also up to you.
我相信你可以自己解决剩下的问题,对于你可能想要寻找的标题main=和y轴标签也取决于你。
If you want to see more of the tails of the distribution, why don't you try playing with the seq(5, 15, )
section? Finally, if you want to know more about what dnorm
is doing I suggest you look here
如果您想要看到更多的分布的尾部,为什么不尝试使用seq(5,15,)部分呢?最后,如果你想知道更多关于dnorm在做什么,我建议你看看这里
#2
7
By the way, instead of generating the x and y coordinates yourself, you can also use the curve()
function, which is intended to draw curves corresponding to a function (such as the density of a standard normal function).
顺便说一下,您可以使用curve()函数,而不是自己生成x和y坐标,它的目的是绘制与函数对应的曲线(例如标准法线函数的密度)。
see
看到
help(curve)
and its examples.
和它的例子。
And if you want to add som text to properly label the mean and standard deviations, you can use the text()
function (see also plotmath
, for annotations with mathematical symbols) .
如果您想添加som文本来正确地标记均值和标准差,您可以使用text()函数(参见plotmath,对于带有数学符号的注释)。
see
看到
help(text)
help(plotmath)
#3
4
Something like this perhaps?
也许是这样的?
x<-rnorm(100000,mean=10, sd=2)
hist(x,breaks=150,xlim=c(0,20),freq=FALSE)
abline(v=10, lwd=5)
abline(v=c(4,6,8,12,14,16), lwd=3,lty=3)
#1
13
I am pretty sure this is a duplicate. Anyway, have a look at the following piece of code
我很确定这是复制品。无论如何,请看下面这段代码
x <- seq(5, 15, length=1000)
y <- dnorm(x, mean=10, sd=3)
plot(x, y, type="l", lwd=1)
I'm sure you can work the rest out yourself, for the title you might want to look for something called main=
and y-axis
labels are also up to you.
我相信你可以自己解决剩下的问题,对于你可能想要寻找的标题main=和y轴标签也取决于你。
If you want to see more of the tails of the distribution, why don't you try playing with the seq(5, 15, )
section? Finally, if you want to know more about what dnorm
is doing I suggest you look here
如果您想要看到更多的分布的尾部,为什么不尝试使用seq(5,15,)部分呢?最后,如果你想知道更多关于dnorm在做什么,我建议你看看这里
#2
7
By the way, instead of generating the x and y coordinates yourself, you can also use the curve()
function, which is intended to draw curves corresponding to a function (such as the density of a standard normal function).
顺便说一下,您可以使用curve()函数,而不是自己生成x和y坐标,它的目的是绘制与函数对应的曲线(例如标准法线函数的密度)。
see
看到
help(curve)
and its examples.
和它的例子。
And if you want to add som text to properly label the mean and standard deviations, you can use the text()
function (see also plotmath
, for annotations with mathematical symbols) .
如果您想添加som文本来正确地标记均值和标准差,您可以使用text()函数(参见plotmath,对于带有数学符号的注释)。
see
看到
help(text)
help(plotmath)
#3
4
Something like this perhaps?
也许是这样的?
x<-rnorm(100000,mean=10, sd=2)
hist(x,breaks=150,xlim=c(0,20),freq=FALSE)
abline(v=10, lwd=5)
abline(v=c(4,6,8,12,14,16), lwd=3,lty=3)