/**************************************************** ECO375 Class1 Example: Sample Distribution (the Central Limit Theorem) *****************************************************/ /* Binomial distribution example This program b1 creates a sample of 100 observations and return the sample mean to meanx. The simulation code will replicate 10000 samples and save as xbbar. bin_sumul : program to simulate random binary distribution */ clear all set obs 1000 gen x0 = rbinomial(1,.5) hist x0, discrete program bin_simul, rclass drop _all quietly set obs 100 gen x = rbinomial(1,.5) summarize x return scalar meanx = r(mean) end simulate xbbar = r(meanx), reps(10000) seed(12345678) : bin_simul sum xbbar hist xbbar /* Normal distribution with 0 mean and 5 standard deviation example The program n1 creates a sample of 100 observations and return the sample mean to meanx The simulation code will replicate 10000 samplesand save as xnbar. */ /* Creating a program called n1 */ program n1, rclass drop _all quietly set obs 100 gen x = rnormal(0,5) summarize x return scalar meanx = r(mean) end simulate xnbar = r(meanx), reps(10000) seed(12345678) : n1 sum xnbar hist xnbar /* End of Code */