Advertisement
Guest User

Untitled

a guest
Jul 31st, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. from random import *
  2. from math import *
  3. from pylab import *
  4. import numpy as np
  5.  
  6.  
  7. def exp_pdf(x,d,l):
  8.  
  9. if x <= d:
  10. return 0
  11. else:
  12. return l * exp( - l * (x-d) )
  13.  
  14. def main():
  15.  
  16. start = 0
  17. end = 20
  18. points = 1000
  19.  
  20.  
  21. X = np.linspace(start,end,points,endpoint=True)
  22. Y = exp_pdf(X,0,1)
  23.  
  24.  
  25. plot(X,Y)
  26.  
  27. show()
  28.  
  29.  
  30. main()
  31.  
  32. Traceback (most recent call last):
  33. File "tests.py", line 34, in <module>
  34. main()
  35. File "tests.py", line 26, in main
  36. Y = exp_pdf(X,0,1)
  37. File "tests.py", line 9, in exp_pdf
  38. if x <= d:
  39. ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement