Normal Distribution

 How do you read normal distribution?

The normal distribution is a continuous probability distribution. The normal distribution is used to study the behavior of continuous random variables like weight, height, and intelligence of a group of students.

How to plot normal distribution in data science?

z <- seq(-3,3,0.01)
> pd <- dnorm(z)
> plot(z,pd,type="l")
> p<-seq(9800,10500,50)
> pda<-dnorm(p)
> plot(p,pda,type="l")
> polygon(c(z[z<=-1],-1),c(pd[z<=-1],pd[z==-3]),col="red")
norma-ldistribution
curve(x^3-3*x, -2, 2)
> x <- seq(-2,2,0.01)
> y <- xˆ3-3*x
Error: unexpected input in "y <- xˆ"
> y <- x^3-3*x
> plot(x,y,type="l")
> x <- seq(-2,2,0.01)
> y <- x^3-3*x
> plot(x,y,type="l")
> xv <- 0:100
> yA <- 482*xv*exp(-0.045*xv)
> yB <- 518*xv*exp(-0.055*xv)
> plot(c(xv,xv),c(yA,yB),xlab="stock",ylab="recruits",type="n")
> lines(xv,yA,lty=2,col="blue")
> lines(xv,yB,lty=1,col="red")
> points(x,y,pch=16)
 values <- rpois(1000,1.70)
> hist(values,main="",xlab="random numbers from a Poisson with mean 1.7")
> hist(values,breaks=(-0.5:8.5),main="",
+      xlab="random numbers from a Poisson with mean 1.7")
> y <- rnbinom(158,mu=1.5,size=1)
> bks <- -0.5:(max(y)+0.5)
> hist(y,bks,main="")
> mean(y)
[1] 1.367089
> var(y)
[1] 3.2784
> mean(y)ˆ2/(var(y)-mean(y))
Error: unexpected input in "mean(y)ˆ"
> mean(y)^2/(var(y)-mean(y))
[1] 0.9778265
> xs <- 0:11
> ys <- dnbinom(xs,size=1.2788,mu=1.772)
> lines(xs,ys*158)
> par(mfrow=c(1,1))
> t <- seq(0.2,4,0.01)
> plot(t,gamma(t),type="l")
> abline(h=1,lty=2)
> par(mfrow=c(2,2))
> x <- seq(0,10,0.1)
> y <- 100/(1+90*exp(-1*x))
> plot(x,y,type="l",main="three-parameter logistic")
> y <- 20+100/(1+exp(0.8*(3-x)))
> plot(x,y,ylim=c(0,140),type="l",main="four-parameter logistic")
> x <- -200:100
> y <- 100*exp(-exp(0.02*x))
> plot(x,y,type="l",main="negative Gompertz")
> x <- 0:100
> y <- 50*exp(-5*exp(-0.08*x))
> plot(x,y,type="l",main="positive Gompertz")
> a <- 10
> b <- -0.8
> c <- 10
> d <- -0.05
> y <- a*exp(b*x)+c*exp(d*x)
> plot(x,y,main="+ - + -",type="l")
> a <- 10
> b <- -0.8
> c <- 10
> d <- 0.05
> y <- a*exp(b*x)+c*exp(d*x)
> plot(x,y,main="+ - + +",type="l")
> par(mfrow=c(1,1))
> x <- 0:6
> plot(x,factorial(x),type="s",main="factorial x",log="y")
> choose(8,3)
[1] 56
> plot(0:8,choose(8,0:8),type="s",main="binomial coefficients")
> curve(pnorm(x),-3,3)
> arrows(-1,0,-1,pnorm(-1),col="red")
> arrows(-1,pnorm(-1),-3,pnorm(-1),col="green")
> pnorm(-1)
[1] 0.1586553
> curve(dnorm(x),-3,3)
> par(mfrow=c(2,2))
> x <- seq(-3,3,0.01)
> x <- seq(-3,3,0.01)
> plot(x,y,type="l",main= "x")
Error in xy.coords(x, y, xlabel, ylabel, log) : 
  'x' and 'y' lengths differ
> y <- exp(-abs(x))
> plot(x,y,type="l",main= "x")
> y <- exp(-abs(x)^2)
> plot(x,y,type="l",main= "x^2")
> y <- exp(-abs(x)^3)
> plot(x,y,type="l",main= "x^3")
> y <- exp(-abs(x)^8)
> plot(x,y,type="l",main= "x^8")
> pnorm(-1.25)
[1] 0.1056498
> pnorm(1.875)
[1] 0.9696036
> 1-pnorm(1.875)
[1] 0.03039636
> pnorm(1.25)-pnorm(-0.625)
[1] 0.6283647
> z <- seq(-0.635,1.25,0.01)
> p <- dnorm(z)
> z <- c(z,1.25,-0.635)
> p <- c(p,0,0)
> plot(x,dnorm(x),type="l",xaxt="n",ylab="probability density",xlab="height")
> axis(1,at=-3:3,labels=c("146","154","162","170","178","186","192"))
> polygon(z,p,col="red")
Reactions

Post a Comment

0 Comments