O.rka O.rka -4 years ago 201
Python Question

Get distribution name from scipy.stats.distribution object? (SciPy | Python 3)

I'm trying out a bunch of different fits for distributions.

Is there any way to get the name of the distribution back from the distribution object?

I found a way but it doesn't seem very efficient.

distribution = "gamma"
distr = getattr(stats, distribution)
# <scipy.stats._continuous_distns.gamma_gen object at 0x11688f518>
# 'gamma'

Answer Source

Use the name attribute:

>>> from scipy import stats
>>> distribution = "gamma"
>>> distr = getattr(stats, distribution)
>>> distr.name
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download