###################################################################### # random sample from the normal distribution, estimate the parameters # simulated sample mu <- 43; sigma <- 5.97 # parameters n <- 300 x <- rnorm(n, mu, sigma) hist(x,freq=FALSE) # estimate the parameters with x.bar and sd mu.hat <- mean(x); mu.hat sigma.hat <- sd(x); sigma.hat # plot the fitted model on the histogram curve(dnorm(x,mu.hat,sigma.hat),add=T) ###################################################################### # random sample from the exponential distribution, estimate the parameters # simulated sample lambda <- 11.34 # parameters n <- 30 x <- rexp(n, rate=lambda) hist(x,freq=FALSE) # estimate the parameters with x.bar and sd lambda.hat <- 1/mean(x); lambda.hat # plot the fitted model on the histogram curve(dexp(x,lambda.hat),add=T) ###################################################################### # now suppose we want to fit the gamma distribution to a random sample # how can we do this? can we use x.bar and the sd? # The big question is, how do we estimate parameters in models in general? ######################################################################