Cauchy distribution. Draw 1000 sets of numbers from the Cauchy distribution using set.seed(100). Do this for set size 2, 5, 10 and 20. Compute the median of each set (use a matrix and apply()). Study the distribution of the medians, for each set size.

  • $\begingroup$ Programming questions are off topic here. Consider highlighting the statistical aspect of your problem if there is any. $\endgroup$ – Richard Hardy Aug 29 at 11:58

Programming library functions usually yield uniformly distributed random numbers. To generate random numbers distributed according to a different distribution, there are two methods:

  1. Transformation method
  2. Rejection method

As your question looks like a homework assignment, you have most probably covered both methods in the respective course and this is an exercise for the methods. In this case, the transformation method is appropriate, because the CDF of the Cauchy distribution can be readily inverted:

$$y = \frac{1}{2} + \frac{1}{\pi}\arctan(x) \iff x = \tan(\pi y - \pi/2)$$

Or you enter ?rcauchy in R ;-)

| cite | improve this answer | |