Homework 5

  1. Study Chapters 24-26 of Shotts.
  2. Study Chapter 10 & 12 of Jones, Maillardet, & Robinson.
  3. Recall that the script 'root-finding.R' and 'root-finding.py' from a previous lecture sourced scripts to define the 'secant' and 'bisection' functions. Provide your own implementation of these functions using the same filenames. Make your code as efficient as possible, evaluating the supplied function as few times as possible. Also, make your functions general so they will work with other inputs than those used in the examples.
  4. Using the instructions for Simpson's rule in Numerical Integration document, write a function called 'simpsons' as a function of the number of bins. Using the function from the intfun.R and intfun.py script we used in class, determine a way to classify the error of Simpson's integration as a function of n. Does your results match with the theory shown in the Numerical Integration document? Put the results in a script called simpsons.ext.
  5. The logit-normal distribution is supported between 0 and 1. The pdf of the distribution can be found here. Note that the website says that there is no analytical solution for the moments. Write a function entitled logit.normal that takes sigma and mu as input variables and returns the mean and the variance using numerical integration. Use trapeziodal rule for integration and be sure to use enough bins that you are comfortable with the result. Do not use built in integrate functions! Put the code for this problem and problem 6 into a file logitnormal.ext
  6. Use the code you used in the previous problem. Fix the value for sigma to be 0.5. Use root finding methodology to determine the value of mu that makes the mean of the distribution equal to pi/4.
  7. Submit this homework by committing the necessary files (including any data files) in the appropriate directory and pushing to your central Git repository. Remember to not commit files that are easily reproducible.