0

I want to computer gamma fit over the axis 0 from my array (3d). I've try the code below but something its wrong.

import scipy.stats as st
import numpy as np
myarray = np.random.rand(20, 3, 3)
a, myloc, myscale = st.gamma.fit(myarray, axis=0)
marcelorodrigues
  • 919
  • 5
  • 12
  • 22
  • *"something its wrong"* [sic]. That is almost never enough of an explanation. Please explain *what* is wrong. If you got an error, include the complete error message (i.e. the full traceback) in the question. If the result is not what you expected, show the result that you got, and explain why it is not what you expected. – Warren Weckesser Jun 02 '15 at 20:28

2 Answers2

1

The fit method does not accept an axis argument.

Actually, in scipy 0.15.1 (and probably older versions), it does "accept" it, but it ignores it. This looks like a bug. It should raise a TypeError when you give it any argument that it doesn't actually use, but that is not how it currently works:

In [20]: from scipy.stats import gamma

In [21]: gamma.fit([1,2,3,3,3,4,5,7])
Out[21]: (3.6899039741659925, 0.049374155400321737, 0.93515411814698823)

In [22]: gamma.fit([1,2,3,3,3,4,5,7], axis=123)
Out[22]: (3.6899039741659925, 0.049374155400321737, 0.93515411814698823)

In [23]: gamma.fit([1,2,3,3,3,4,5,7], flibbity=123)
Out[23]: (3.6899039741659925, 0.049374155400321737, 0.93515411814698823)

Bug report: https://github.com/scipy/scipy/issues/4932

Warren Weckesser
  • 110,654
  • 19
  • 194
  • 214
0

It should be scipy.stats instead of scipy.stat.

Ami Tavory
  • 74,578
  • 11
  • 141
  • 185
maxymoo
  • 35,286
  • 11
  • 92
  • 119