2013-02-21 95 views
0

我是R和统计学的新手,我仍然理解基本概念。我需要根据高斯曲线创建一列矩阵中所有值的图形。 下面是代码对高斯曲线的绘图值

#Generates a random matrix with 50 columns 
randomMatrix1 <- matrix(c(1:30000), ncol=50) 

#Base sequence 
x <- seq(15001,30000, 25) 

#Normal function using mean and sd of randomMatrix1 
y1 <- dnorm(x/1000,mean=mean(randomMatrix1[,50]),sd=sd(randomMatrix1[,50])) 

#Getting the actual values in randomMatrix1 
y2 <- cbind(randomMatrix1[,50]/1000) 

df <- data.frame(x,y1,y2) 


require(ggplot2) 

ggplot(df, aes(x)) +     # basic graphical object 
geom_line(aes(y=y1), colour="red") + # first layer 
geom_line(aes(y=y2), colour="green") # second layer 

我需要同积两个地块的输出,但输出不进行缩放,我尝试不同的均值和SD但是毫无效果的某种组合。

我知道这一定是一个非常基本的问题,但是我应该更改哪个参数,这样两个图可以缩放并显示在一起。

+0

我会帮但我不知道是什么'meanMat'或'stdDev'以上。 – N8TRO 2013-02-21 06:26:53

+0

我的不好。这是一个错字。现在修复它。 – user2085566 2013-02-21 06:39:22

回答

0

我不确定我是否理解这个问题,但这有帮助吗?

​​

enter image description here