#Biostatistics 080 #CREATING A PSEUDORANDOM NORMAL DISTRIBUTION: X=rnorm(1000,65,25) hist(X,nclass=50,col="gray",border="red") #STANDARDIZING DATA: mu=mean(X) sigma=sd(X) Z=(X-mu)/sigma Z[1:10] hist(Z,nclass=50,col="gray",border="red") Z2=scale(X,center=TRUE,scale=TRUE) Z2[1:10] #PQ FUNCTIONS FOR NORMAL DISTRIBUTION: mu=0 sigma=1 X=1.6449 PHI=0.90 dnorm(X,mu,sigma) # point estimate P(X) given X pnorm(X,mu,sigma) # cumulative phi(X) given X qnorm(PHI,mu,sigma) # X given cumulative phi(X) #EXAMPLE INTERVAL CALCULATIONS: mu=0 sigma=1 MIN=pnorm(-1,mu,sigma) MAX=pnorm(1,mu,sigma) MAX-MIN MIN=pnorm(-2.576,mu,sigma) MAX=pnorm(2.576,mu,sigma) MAX-MIN MIN=pnorm(-1.96,mu,sigma) MAX=pnorm(1.96,mu,sigma) MAX-MIN #QUANTILES Q=qnorm(0.975,mu,sigma) Q PHI=seq(0.025,0.975,0.025) PHI Q=qnorm(PHI,mu,sigma) Q