You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Name of QuantLet : MSMasymptoticnormality1Published in : MSMDescription : 'Transforms a random variable with a given mean and variance to an asymptoticstandard normal distribution.'Keywords : standard-normal, asymptotic, graphical representation, pdf, randomAuthor [New] : Luis Alejandro Sarmiento AbogadoSubmitted : Mon, February 08 2016 by Chen Huang
R Code:
## clear history
rm(list= ls(all=TRUE))
graphics.off()
## Generate a set of random variables following a normal distributionm=2s=0.5random= rnorm(n=1e+05, mean=m, sd=s)
## Determine their correspondent means, standard deviations and variancesmu= mean(random)
sd= sd(random)
var= var(random)
## Set the transformation functionY=function(mu, sd, random) {
(random-mu)/sd
}
## Compute the new set of random variables under standard normal distributionX= (random-mu)/sd## Determine the mean and variance of our transformation
mean(X)
var(X)
## Plot the results to show that X is asymptotically normal distributed## Plot initial distribution
plot(density(random), col="red", xlim= c(-m*2, m*2), ylim= c(0, 1), lwd=2,
main="Densities comparison", xlab="")
## Plot Transformation
lines(density(X), col="blue", lwd=2)
## Set the legend
legend("topleft", legend= c("Standard Normal Distribution", "Initial Distribution"),
lty=1, col= c("blue", "red"), cex=0.9)