R语言中各种分布
rnorm(n,mean=0,sd=1) rexp(n,rate=1) rgamma(n,shape,scale=1) rpois(n,lambda) rweibull(n,shape,scale=1)#weibull分布 rcauchy(n,location=0,scale=1)#Cauchy分布 rbeta(n,shape1,shape2)#beta分布 rt(n,df)#t分布 rf(n,df1,df2)#F分布 rchisq(n,df)#卡方分布 rbinom(n,size,prob)#二项分布 rgeom(n,prob)#几何分布 rhyper(nn,m,n,k)#超几何分布 rlogis(n,location=0,scale=1)#logistic分布 rlnorm(n,meanlog=0,sdlog=1)#对数正态 rnbinom(n,size,prob)#负二项分布 runif(n,min,max)#均匀分布
median(x1) [1] 99 quantile(x1) 0% 25% 50% 75% 100% 86 95 99 105 115 fivenum:中位数,上四分位数,下四分位数,最大值,最小值 cor:相关系数 cos:协方差
一元线性回归分析
lm: linear model a=lm(w~1+h) summary(a) Call: lm(formula = y ~ x) Residuals:(对残差的描述) Min 1Q Median 3Q Max -1.81085 -0.66032 0.01576 0.67239 1.60354 Coefficients: Estimate St