In [30]:
import numpy as np
from scipy.stats import uniform
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
def generate(size=1):
# Generate a point uniformly distributed in the square [-1, 1] x [-1, 1]
x = uniform.rvs(loc=-1, scale=2, size=size)
y = uniform.rvs(loc=-1, scale=2, size=size)
# Normalize by the distance from the origin to get a point on the unit circle
r = np.sqrt(x**2 + y**2)
return np.column_stack([x / r, y / r])
In [33]:
dat = generate(100000)
In [34]:
dat.shape
Out[34]:
In [35]:
plt.plot(dat[:,0], dat[:,1], '.')
plt.gca().set_aspect('equal')
In [36]:
plt.hist2d(dat[:,0], dat[:,1], 20, norm=LogNorm())
plt.gca().set_aspect('equal')
plt.colorbar()
Out[36]:
In [ ]:
R = 1
theta =
In [ ]: