Fitting distribution with fixed parameters in SciPy

后端 未结 1 1333
渐次进展
渐次进展 2021-01-18 20:27

Is it possible to fix parameters while fitting distributions in SciPy? For example, this code:

import scipy.stats as st
xx = st.expon.rvs(size=100)
print st.         


        
1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-18 20:51

    To fix loc, use the argument floc:

    print st.expon.fit(xx, floc=0)
    

    E.g.

    In [33]: import scipy.stats as st
    
    In [34]: xx = st.expon.rvs(size=100)
    
    In [35]: print st.expon.fit(xx, floc=0)
    (0, 0.77853895325584932)
    

    Some related questions:

    • Gamma distribution fit error
    • Why does the Gamma distribution in SciPy have three parameters?
    • Fitting non-normpdf's to histograms in matplotlib

    0 讨论(0)
提交回复
热议问题