0

Please could someone verify that the first parameter in a scipy.stats.chi2.fit for some data is actually the number of degrees of freedom df? Here is an example of what I'm checking

x=np.random.rand(1000)
y=stats.chi2.pdf(x,df=1)
z=np.log10(y)
# assume z is the distribution of a rv in logspace

# is this line correct for the mles?
df, loc, scale = stats.chi2.fit(z)

Only if I check for example something like

x=np.random.rand(1000)
y=stats.chi2.pdf(x,df=1.5)
z=np.log10(y)
# assume z is the distribution in logspace
df, loc, scale = stats.chi2.fit(z)

It returns

(2.686925741184449, -0.5319434585863583, 0.08411242959515701)

Where I am not sure if the fit is correct?

Thanks!

MKF
  • 105
  • 7
  • Maybe you find something here: https://github.com/scipy/scipy/blob/v1.6.1/scipy/stats/_continuous_distns.py#L1234 – igorkf Mar 04 '21 at 18:17
  • When you do `fit(z)` you're not fitting a sample to a chi2 distribution... the `fit` is made to fit observations to a distribution. You're fitting y-values of a transformed PDF. – Max Pierini Mar 27 '21 at 15:06

0 Answers0