0

I am working in python and I have some performance data of some actions

DailyReturn = [0.325, -0.287, ...]

I've been trying to fit a normal distribution and a student's t-distribution to the density histogram of that data to use as a PDF. I would like to get the adjustment parameters, the standard errors of the parameters and the value of the LogLikelihood by the method of MLE (maximum likelihood). But I have run into some issues. At the moment I have this idea

import numpy as np
import math
import scipy.optimize as optimize
import statistics
def llnorm(par, data):
    n = len(data)
    mu, sigma = par
    ll = -np.sum(-n/2*math.log(2*math.pi*(sigma**2))-((data-mu)**2)/(2*(sigma**2)))
    return ll
data = DailyReturn
result = optimize.minimize(llnorm, [statistics.mean(data),statistics.stdev(data)], args = (data)

But I'm not sure and I'm lost with the t student distribution, is there an easier way to do it?

physics
  • 21
  • 1

1 Answers1

0

In scipy.stats you find several distributions, amongn them student's T and normal

These modules have a fit method. You can see an example here for normal distribution.

Your approach seems to be correct to normal distribution, I there is no point in this case since the optimal solution will be given by the mu and sigma you are passing.

Bob
  • 13,867
  • 1
  • 5
  • 27