[R] describes the statistical analysis of the data distribution

Distribution function

Normal distribution

dnorm probability density function f (x), distribution law or PK
P norm distribution function F. (X)
qnorm inverse function F-1§ distribution function, i.e. after a given probability p, find its lower quantile
rnorm generates a random number

r<-rnorm(100,0,1)
dnorm(x,mean=0,sd=1)
pnorm(q,mean=0,sd=1)
qnorm(p,mean=0,sd=1)
rnorm(n,mean=0,sd=1)

Here Insert Picture Description

Possion distribution

dpois(x,lambda)
ppois(q,lambda)
qpois(p,lambda)
rpois(n,lambda)

Here Insert Picture Description

Other distribution function or distribution law

distributed R Software name Additional parameters
binomial binom size, prob
Cauchy cauchy location scale
chi-squared chisq df, ncp
exponential exp rate
F f df1,df2,ncp
geometric geom prob
hypergeometric hyper m,n,k
log-normal lnorm meanlog,sdlog
logistic logis location,scale
normal norm mean,sd
Possion because lambda
Student’s t t df,ncp
uniform unif min,max
Weibull weibull shape,scale
beta beta shape1, shape2, nec

Graph

Binomial

n<-20
p<-0.2
k<-seq(0,n)
plot(k,dbinom(k,n,p),type='h',main='Binomial distribution, n=20, p=0.2',xlab='k')

Here Insert Picture Description

Poisson distribution

lambda<-4.0
k<-seq(0,20)
plot(k,dpois(k,lambda),type='h',main='Poisson distribution, lambda=5.5',xlab='k')

Here Insert Picture Description

Geometric Distribution

p<-0.5
k<-seq(0,10)
plot(k,dgeom(k,p),type='h',main='Geometric distribution, p=0.5',xlab='k')

Here Insert Picture Description

Hypergeometric distribution

N<-30
M<-10
n<-10
k<-seq(0,10)
plot(k,dhyper(k,N,M,n),type='h',main='Hypergeometric distribution,N=30, M=10, n=10',xlab='k')

Here Insert Picture Description

Negative binomial distribution

n<-10
p<-0.5
k<-seq(0,40)
plot(k, dnbinom(k,n,p), type='h',main='Negative Binomial distribution,n=10, p=0.5',xlab='k')

Here Insert Picture Description

Distribution

Histogram and kernel density estimation function

Student body weight histogram and kernel density estimation map, and with normal probability density function of the relative ratio

w <- c(75.0, 64.0, 47.4, 66.9, 62.2, 62.2, 58.7, 63.5, 66.6, 64.0, 57.0, 69.0, 56.9, 50.0, 72.0)
hist(w, freq=FALSE)
lines(density(w),col="blue")
x<-44:76
lines(x, dnorm(x, mean(w), sd(w)), col="red")

The results obtained are shown in:
Here Insert Picture Description

Empirical distribution

FIG empirical distribution and corresponding distribution plot

w <- c(75.0, 64.0, 47.4, 66.9, 62.2, 62.2, 58.7, 63.5, 66.6, 64.0, 57.0, 69.0, 56.9, 50.0, 72.0)
plot(ecdf(w),verticals = TRUE, do.p = FALSE)
x<-44:78
lines(x, pnorm(x, mean(w), sd(w)))

Here Insert Picture Description

Normal QQ FIG.

w <- c(75.0, 64.0, 47.4, 66.9, 62.2, 62.2, 58.7, 63.5, 66.6, 64.0, 57.0, 69.0, 56.9, 50.0, 72.0)
qqnorm(w); qqline(w)

Here Insert Picture Description

Stem and Leaf

x<-c(25, 45, 50, 54, 55, 61, 64, 68, 72, 75, 75, 
     78, 79, 81, 83, 84, 84, 84, 85, 86, 86, 86, 
     87, 89, 89, 89, 90, 91, 91, 92, 100)
stem(x) 

Here Insert Picture Description

Boxplot

The two methods of data

A <- c(79.98, 80.04, 80.02, 80.04, 80.03, 80.03, 80.04,
       79.97, 80.05, 80.03, 80.02, 80.00, 80.02)    
B <- c(80.02, 79.94, 79.98, 79.97, 79.97, 80.03, 79.95, 79.97)        
boxplot(A, B, notch=T, names=c('A', 'B'), col=c(2,3))

Here Insert Picture Description

All in all the number five

x<-c(25, 45, 50, 54, 55, 61, 64, 68, 72, 75, 75, 
     78, 79, 81, 83, 84, 84, 84, 85, 86, 86, 86, 
     87, 89, 89, 89, 90, 91, 91, 92, 100)
fivenum(x)

Here Insert Picture Description

Published 20 original articles · won praise 14 · views 862

Guess you like

Origin blog.csdn.net/weixin_43645790/article/details/103918177