Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. import numpy as np
  2.  
  3. def get_values():
  4. x = np.arange(-15, 10)
  5. y = np.empty(30)
  6. start = np.random.randint(10, 85)
  7. y[0] = start
  8.  
  9. i = 0
  10.  
  11. while i < 25:
  12. if i > 1 and y[i-2] < y[i-1]:
  13. if np.random.rand() < 0.2:
  14. y[i + 1] = y[i]
  15. i = i+1
  16. continue
  17. elif np.random.rand() < 0.1:
  18. y[i + 1] = y[i]
  19. y[i + 2] = y[i]
  20. y[i + 3] = y[i]
  21. i = i+3
  22.  
  23. if y[i] >= 100:
  24. y[i] = np.random.randint(82, 98)
  25. curr = y[i]
  26. i += 1
  27. if curr < np.random.randint(15, 30):
  28. if np.random.rand() < 0.1:
  29. y[i] = curr - np.random.randint(4, 6)
  30. else:
  31. while y[i] < np.random.randint(70, 98):
  32. y[i] = y[i - 1] + np.random.randint(25, 35)
  33. if i > 25:
  34. break
  35. if y[i] > 95:
  36. y[i] = np.random.randint(82, 98)
  37. i -= 1
  38. continue
  39. i += 1
  40.  
  41. else:
  42. y[i] = curr - np.random.randint(3, 10)
  43.  
  44. if y[i] >= 100:
  45. y[i] = np.random.randint(82, 98)
  46.  
  47. return x.tolist(), y.tolist()[:25]
  48.  
  49. def get_data():
  50. x, y = get_values()
  51. return [[i, y if i <= 0 else None, y if i >= 0 else None] for x, y, i in zip(x, y, range(-15,11))]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement