Normal Distributions
The normal density function is calculated bypdf = dnorm(x, mu, sigma)with mean parameter


pnorm(x, mu, sigma)returns 0 or 1 when x=-Inf or x=+Inf is specified respectively. Some of arguments typically have their default values. The values mu = 0 and sigma = 1 are set by default for dnorm() and pnorm(), and
y = dnorm(x)returns the values of the standard normal density function at x. Standard normal distribution table contains the area under the standard normal curve



mu = 10 sigma = 5 intval = c(5,20); range = c(mu-3.5*sigma,mu+3.5*sigma); x = seq(range[1], range[2], length=100); y = dnorm(x,mu,sigma); plot(x, y, type='l', lwd=1, frame.plot=F, main='Normal Distribution'); x = seq(max(c(range[1],intval[1])), min(c(range[2],intval[2])), length = 50); y = dnorm(x,mu,sigma); polygon(c(x,max(x),min(x)), c(y,0,0), col = 'green'); prob = pnorm(intval[2],mu,sigma) - pnorm(intval[1],mu,sigma); text((min(x)+max(x))/2, 0, round(prob,digits=4), pos=3); prob
Programming Note.
The function text(x,y,string)
displays the string at the coordinate
on the graphics.
The option pos=n specified the position (1) below, (2) to the left, (3)
above and (4) to the right of the coordinates.
Sample R code. You can download normal.R, and run it.
Quantile function. The quantile function of normal distribution is obtained by qnorm().
c = qnorm(p,mu,sigma)returns the value


p = 0.95; range = c(-5,5); x = seq(range[1], range[2], length=100); y = dnorm(x); plot(x, y, type='l', lwd=1, frame.plot=F); cvalue = qnorm(p); x = seq(min(c(range[1],cvalue)), cvalue, length = 50); y = dnorm(x); polygon(c(x,max(x),min(x)), c(y,0,0), col = 'green'); text(x[50]-2, 0.05, p); text(x[50],0.2*y[50], round(cvalue,digits=4), pos=4); cvalue
Sample R code. You can download qnorm.R, and run it.
© TTU Mathematics