문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top