简体   繁体   中英

Call scipy.stats probability distributions like normal python functions

from scipy.stats import uniform

How can I call uniform.pdf like a normal python function? I want to work with the probablility distribution functions like one can work with regular python functions in terms of integration and differentiation.

integrate.quad(uniform.pdf, xlimits['value'][0], xlimits['value'][1]))

scipy.stats.uniform.pdf is a Python function meaning that it is callable just like any other function.

from scipy.stats import uniform
import numpy as np

x = np.linspace(0,1,10)

pdf = uniform.pdf(x) # Create a uniform pdf over the range [0,1].

print(pdf)
# [ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.]

You can see the arguments that uniform.pdf() takes at the bottom of this docs page .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM