TAGS :Viewed: 9 - Published at: a few seconds ago

[ scipy: Which distributions have a "fit" function implemented? ]

scipy has over a hundred distributions in their stats module, but not all them have a "fit" function implemented. Is there a way to check which distributions have it and which don't?

Answer 1


How about this?

def distswith(fn='fit'):
    """prints out distributions with '.fit' methods. 
    where any class with a '._pdf' method is considered a distribution
    """
    import scipy.stats
    for fn in dir(scipy.stats):
        fns=eval('dir(scipy.stats.'+fn+')')
        if '_pdf' in fns and 'fit' in fns: 
            print fn

EDIT: looks to me like all 86 do.