0

This question has been asked before here. However, the solution does not seem to work with the current version of Scipy any more.

To review, I would like to know what parameters some arbitrary Scipy distribution would require before instantiating it. The existing solution (that does not seem to work anymore, or for me at least) is as follows:

import inspect
import scipy.stat as st
def get_params(scipy_dist):
    return [param for param in inspect.signature(scipy_dist._pdf).parameters if param != 'x']

Unfortunately, if one calls this on say st.norm or st.expon then it returns ['kwds'].

Is there an alternative way of obtaining the parameters?

Dylan Solms
  • 330
  • 2
  • 10

1 Answers1

0

You seem to be looking for the shapes attribute. stats.expon.shapes returns the string of comma-deparated names for shape parameters for the full signature, add "loc, scale" for continuous distributions and "loc" for discrete ones.

ev-br
  • 24,968
  • 9
  • 65
  • 78