0

I'm trying to fit a Levy-Stable distribution on to a histogram that I've already plotted:

Histogram of data

1

The "daily change" values were calculated from a pandas dataframe, using df.diff(), so that it returned a set of values containing the difference between successive rows (of a particular column) of the original .csv file.

I'm looking for a straightforward way to fit a Levy-stable dist. onto the histogram, given that I have already found the bin centers. I'm also looking for optimized fit parameters. Note that I'm not referring to the specific case of Levy dist. but the general case of the levy-stable dist.

I'm aware that I'd need to calculate the bin centers on the histogram, to fit any curve onto the histogram. Usually, to perform a curve fit or use scipy to optimize, we need a specific analytic, closed-form expression for the function we are trying to fit. However, the Levy-stable dist. has no such expression. It's the FT of the characteristic function, but trying to take that route would likely take too long.

I've plotted the dist. on the same set of axes as the histogram, just to see what I'd get:

Levy-stable and histogram, same axes

2

To do this, I've imported levy_stable from scipy.stats and set alpha = 1.8, beta = -0.5, as test values, with moments = 'mvsk':

alpha, beta = 1.8, -0.5

mean, var, skew, kurt = levy_stable.stats(alpha, beta, moments='mvsk')

and x is given as:

x = np.linspace(levy_stable.ppf(0.1, alpha, beta), levy_stable.ppf(0.99, alpha, beta), 100))

This is simply following the documentation on scipy.stats.levy_stable. Then I plotted using:

plt.plot(x, levy_stable.pdf(x, alpha, beta))

vimuth
  • 5,064
  • 33
  • 79
  • 116

0 Answers0