kith
kith

Reputation: 5566

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?

Upvotes: 1

Views: 81

Answers (1)

Rian Rizvi
Rian Rizvi

Reputation: 10825

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.

Upvotes: 2

Related Questions