I need to complete the function exponentialPDF
but get an error:
'IndexError: index 0 is out of bounds for axis 0 with size 0'
The function looks like this:
def uniformPDF(x,a=0.0,b=4.0):
p = 1.0/(b-a)*ones((len(x),))
p[x<a] = 0.0
p[x>b] = 0.0
return(p)
def exponentialPDF(x,a=1.0):
"""
Call:
p = exponentialPDF(x,a)
Input argument:
vals: float (array)
Output argument:
p: float (array)
Examples:
In[1]: exponentialPDF([1,2],3)
Out[1]: array([ 0.14936121, 0.03332699])
"""
p = a * exp(-a*x)
p[x<0] = 0.0
return(p)
Can someone help me with the error?