Advertisement
vatman

Untitled

Dec 19th, 2023
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3.  
  4. def logistic_map(r, x):
  5. return r * x * (1 - x)
  6.  
  7. r = 3.5 # Задайте значение r здесь
  8. x = 0.5 # Задайте начальное значение x здесь
  9.  
  10. # Создаем фигуру и оси
  11. fig, ax = plt.subplots(1, 1, figsize=(10, 10), dpi=80)
  12.  
  13. # Строим линию y=x
  14. ax.plot([0, 1], [0, 1], 'k')
  15.  
  16. # Строим логистическую функцию
  17. t = np.linspace(0, 1, 100)
  18. ax.plot(t, logistic_map(r, t), 'r')
  19.  
  20. # Выполняем итерационный процесс и строим соответствующие линии
  21. for _ in range(100):
  22. y = logistic_map(r, x)
  23. ax.plot([x, x], [x, y], 'b', linewidth=1)
  24. ax.plot([x, y], [y, y], 'b', linewidth=1)
  25. x = y
  26.  
  27. # Настраиваем график
  28. ax.set_xlim(0, 1)
  29. ax.set_ylim(0, 1)
  30. ax.set_title("Графический анализ логистического отображения")
  31. ax.set_xlabel("x")
  32. ax.set_ylabel("h(x)")
  33.  
  34. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement