I need to write a program that generates random implementations of the Cauchy distribution
=%5Cfrac%7B1%7D%7B%5Cpi%7B(1+x%5E%7B2%7D)%7D%7D)
with zero location and units scale.
I also need to make a histogram between -5 and 5 cells, for a random implementation of 1000 points, together with a theoretical curve , to make sure that they have the same units.
I calculated the cumulative distribution function
for the Cauchy distribution:
![F (x) = tan [{\ pi {(rand () - {\ frac {1} {2})}}}] gif.latex? F (x) = tan [% 7B% 5Cpi% 7B (rand () -% 7B% 5Cfrac% 7B1% 7D% 7B2% 7D)% 7D% 7D% 7D]](https://fooobar.com/https://latex.codecogs.com/gif.latex?F(x)=tan%5B%7B%5Cpi%7B(rand()-%7B%5Cfrac%7B1%7D%7B2%7D)%7D%7D%7D%5D)
And I wrote the following python code:
from __future__ import division
import scipy
import random
import matplotlib.pyplot as plt
import numpy as np
import math as m
valuesX = []
for q in range(1000):
R = random.random()
x = m.tan(m.pi*(R-0.5))
valuesX.append(x)
z = np.linspace(-10,10,1000)
y = 1/(m.pi*(1+z**2))
plt.plot(y,z)
plt.hist(valuesX, bins = 50, range = [-5,5], normed=True)
My results: 
, , ( ) . ? .