# How to generate samples from a cauchy distribution

For an assignment I have to draw samples of different sizes from a Cauchy distribution in order to show that as the sample size increases, the mean does not tend to any number (therefore the mean does not exist). However, I have been having trouble trying to figure out how to properly create my Cauchy distribution.

Knowing that a cauchy distribution is simply a variable computed using the ratio of two independent standard normal variables, I created two standard normal variables and then divided them to create this new Cauchy variable. I then found the sample mean, and repeated the process for sample sizes of 10, 100, 500, 1000, 5000, and 10,000.

The following code is the same process that I used for each sample size:

`a_c1= randn(10,1)a_c2= randn(10,1)a_c1ovrc2=a_c1/a_c2a_c1ovrc2( :, ~any(a_c1ovrc2,1) )= [] %in order to delete all the unnecessary zero columns(I don't understand why they were created in the first place)a_c1ovrc2_m = mean(a_c1ovrc2)`

The above table are the values i obtained after completing each operation separately. I don’t feel like this accurately shows that the Cauchy distribution has no mean. Any advice as to what I might be doing wrong would be sincerely appreciated!

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help , Finance Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

`a_c1ovrc2( :, ~any(a_c1ovrc2,1) )= []`

“in order to delete all the unnecessary zero columns(I don’t understand why they were created in the first place)”

They came from the preceding line

`a_c1ovrc2=a_c1/a_c2;`

HINT: See

`doc ./  % follow links to "Arithmetic Operators" at bottom`

After perusing these, all should become clear…