Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. Copy and paste the code above and modify it to produce a 95%-confidence interval for o. . Change xbar to s. . On Line
2. Copy and paste the code above and modify it to produce a 95%-confidence interval for o. . Change xbar to s. . On Line 11, change mean () to the appropriate command for standard deviation. . Add a histogram for (n - 1)82 where so = 80 . s. sorted[left] and s. sorted [right] are bounds for s, not o. In order to find the bounds for we observe that xi = (n - 1)s where s = s. sorted[left] XR = (n - 1)sh where sp = s. sorted [right]. So the bounds for o is(See Worksheet #8) n - n - Xi SR SL . You can find the theoretical values for x} and x} as xi = qchisq(a/2, df = degrees of freedom), x1 = qchisq(1 - a/2, df = degrees of freedom) Then, compute the lower and the upper bounds for o as in the previous step. . Run the code and observe that the distribution of s is skewed (asymmetric) as for the x3 distri- bution. Also the numerical result for the confidence interval should match the theoretical result within a relatively small error.Monte Carlo Methods Monte Carlo methods are a class of numerical algorithms that use random numbers to compute a wide variety of quantities such as integrals (i.e., areas or volumes), probabilities, and expectation values. They are widely used in physics, chemistry, economics, and statistics to name a few. In this assignment, we will use Monte Carlo simulation to compute various confidence intervals. The following code computes a 95%-confidence interval for the population mean given a sample with n = 4, = = 21.3, and 9 =0.7, assuming that 9 8 0- 1. Copy the following code to your script file and study how it works. 1 # Confidence interval for population mean 2 xb0 = 21.3 # Sample mean 3 80 = 0.7 # Sample s.d. Assume 20 is approximately equal to signa 4 n = 4 # sample size (number per sample) 5 alpha = 0.05 # significance level 6 na = 1000 # number of samples to be generated 7 population = rnorm (3000, mean=xb0, ad=:0) # generate normally distributed random numbers 8 hist (population, breaks=30) 10 xbar=rep(0, na) # initialize xbar's 11 for(i in 1:ns) xbar[i] = mean( sample(population, n) ) # Repeat ns times 12 hist (xbar, breaks=30) # Display sampling distribution 13 14 left = round (na*alpha/2); right = round(na* (1-alpha/2)) 15 xbar . sorted = sort (xbar, method="quick") 16 cat ("Simulation: ", xbar . sorted [left], "
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started