0

I want to plot the PDF of a wrapped Cauchy distribution, but when I set a value for the location, the entire distribution gets shifted, rather than wrapped.

When I run this:

from scipy.stats import wrapcauchy
import numpy as np

c = 0.3

rv = wrapcauchy(c, loc = np.pi/2)
x = np.linspace(rv.ppf(0.01),
                rv.ppf(0.99), 100)

plt.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')

plt.xticks(np.arange(0, 2*np.pi), size='small', rotation=0)    
plt.xlabel('θ (Rad)')
plt.ylabel('pdf(θ)')

plt.show()

I get :

enter image description here

The distribution is supposed to stay between 0 rad and 2pi rad, like this :

enter image description here

Any ideas on how I can fix this ? Or are there any other libraries that I could try ? I just need to be able to generate random samples and the PDF of a wrapped Cauchy or Von Mises/Normal with specific modes/means.

Thanks

Liam F-A
  • 135
  • 11

0 Answers0