[SOLVED] 代写代考 Simpson’s rule

30 $

File Name: 代写代考_Simpson’s_rule.zip
File Size: 273.18 KB

SKU: 2286887594 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


Simpson’s rule
For this question, you are required to write two R functions, to examine the accuracy of Simpson’s rule when calculating
P(a PowCoder代写 加微信 assignmentchef

P(a < X < b) = 16as well as its approximation using Simpson’s rule. For the exact value, you should use the pnorm() command in R. Thearguments to your function should be: mu, the mean of the distribution (i.e. u in the formulae above); sigmasq, the variance(i.e. o2 in the formulae); a and b, the integration limits a and b; and n, the value of n to use in Simpson’s rule. The default value ofn should be 100. Your function should return a list containing components p. approx, the Simpson approximation to theprobability; p. exact, the value obtained using pnorm () ; n, the value of n; and p. error, the difference p.approx-p. exact.You may use the dorm () command to calculate the normal probability density function if you wish.Your second function should be called simpsonTest (). Its purpose is to evaluate the error of the Simpson approximationto P(a < X ≤ b) for different values of n, and to estimate the value of a as described in the introduction above. The arguments tothis second function should be: mu, sigmasq, a, b, and n. grid. These all have the same interpretation as the correspondingarguments to normprob () , except for n. grid which should be a vector of values for n. Your SimpsonTest () function shoulduse normprob () to obtain a vector of approximation errors for each value of n in n. grid. It should then use 1m () to regress thelog of the absolute approximation error against the log of n. grid, and take the estimated slope of the regression as an estimateof -a. The function should return a list containing components n. grid (the value of n. grid), abs. error (a vector containingthe absolute values of the approximation errors) and alpha (the estimate of a).IntroductionIn Workshop 3, you looked at the trapezium rule for integrating a function over a finite range. Simpson’s rule is an alternative tothe trapezium rule, which is more accurate. Specifically, for finite integration limits a < b, Simpson’s rule approximateswhere n is an even number, h = (b-a)/n and x; = a + j(b-a)/n.Let en denote the absolute value of the approximation error when Simpson’s rule is used to evaluate an integral. It can be shownthat en is roughly proportional to n’9 for some exponent a, so that log(en) is roughly equal to K – alog(n) for some constant K. Thevalue of a can be established theoretically; but in situations where the exact value of the integral is known, it can also beestimated by evaluating the Simpson approximation for several values of n, calculating the absolute error en each time, and thenregressing log(en) against log(n): the slope of the regression line is an estimate of -a.For this question, you are required to write two R functions, to examine the accuracy of Simpson’s rule when calculatingP(a < Xs b) where X ~ N(4,02) and -o < a < 6 < 00.Your first function should be called normprob (), and should calculate the exact value ofas well as its approximation using Simpson’s rule. For the exact value, you should use the pnorm0 command in R. Thearguments to your function should be: mu, the mean of the distribution (i.e. u in the formulae above); sigmasq, the variance(i.e. o 2 in the formulae); a and b, the integration limits a and b; and n, the value of n to use in Simpson’s rule. The default value ofn should be 100. Your function should return a list containing components p. approx, the Simpson approximation to theprobability; p. exact, the value obtained using pnorm (); n, the value of n; and p. error, the difference p. approx-p. exact.You may use the dorm () command to calculate the normal probability density function if you wish.Your second function should be called SimpsonTest (). Its purpose is to evaluate the error of the Simpson approximation程序代写 CS代考加微信: assignmentchef QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写代考 Simpson’s rule
30 $