Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top