R demos

Back to all R demos
Comparing estimators in Uniform distribution
You can try out the function I used in lecture 10 to demonstrate estimation of the population median in a U(0,theta) distribution.
  1. Download this file: unif.ests.R to your computer, and save it (as unif.ests.R)
  2. Start up R in the usual way
  3. In R, using the Source R code command (on the File menu), navigate to the appropriate folder, and select the file unif.ests.R
  4. Run the demonstration by typing unif.ests()
  5. The function displays a sample of size 10 from the Uniform(0,theta) distribution with theta= 3, together with the three estimators of the population median discussed in lectures
  6. You can control the display with the mouse and pointer
    • You can exit the function by clicking below the horizontal axis
    • If you click anywhere else, a fresh sample is drawn
  7. To change the values of n or theta, run the function by typing apprpriate arguments to the function - the full syntax is unif.ests(n,theta)
  8. If you are interested in seeing how this is all done in R, and perhaps even modifying the actions, you can view the function by simply typing its name (without the () afterwards)