Розмір відео: 1280 X 720853 X 480640 X 360
Показувати елементи керування програвачем
Автоматичне відтворення
Автоповтор
x_steps and y_steps shouldnt be independently sampled. the length and angle should be sampled and then x_step and y_step can be calculated. Thats why the levy flight doesn't travel large distances diagonally in your example
thank you that was useful ,,, but could you share the code file
import numpy as npimport matplotlib.pyplot as pltimport seaborn as snslong_tail_steps = np.random.pareto(a=2, size=100)sns.histplot(long_tail_steps, kde=True)# number of stepsn = 300# generate stepsx_steps = np.random.pareto(a = 2, size = n)y_steps = np.random.pareto(a = 2, size = n)# generate the angleangles = 2 * np.pi * np.random.rand(n)# define the steps and angle for each dimentiondx = x_steps * np.cos(angles)dy = y_steps * np.sin(angles)# turn steps to trajectoryx = np.cumsum(dx)y = np.cumsum(dy)# visualize the levy flightplt.plot(x, y, marker= 'o', markersize=4)plt.grid(True)plt.show()
x_steps and y_steps shouldnt be independently sampled. the length and angle should be sampled and then x_step and y_step can be calculated. Thats why the levy flight doesn't travel large distances diagonally in your example
thank you that was useful ,,, but could you share the code file
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
long_tail_steps = np.random.pareto(a=2, size=100)
sns.histplot(long_tail_steps, kde=True)
# number of steps
n = 300
# generate steps
x_steps = np.random.pareto(a = 2, size = n)
y_steps = np.random.pareto(a = 2, size = n)
# generate the angle
angles = 2 * np.pi * np.random.rand(n)
# define the steps and angle for each dimention
dx = x_steps * np.cos(angles)
dy = y_steps * np.sin(angles)
# turn steps to trajectory
x = np.cumsum(dx)
y = np.cumsum(dy)
# visualize the levy flight
plt.plot(x, y, marker= 'o', markersize=4)
plt.grid(True)
plt.show()