<jupyter_start><jupyter_text>Load data of path points on a 2D plane<jupyter_code>data = np.load('../assets/number2.npy')

path1 = data[:, 0]
path2 = data[:, 1]
n = path1.shape[0]
plt.figure()
plt.scatter(path1, path2)
plt.show()<jupyter_output><empty_output><jupyter_text>Since data is 2D, we need 2 DMPs<jupyter_code># define dmps
dt = 1e-2
T = n * dt
a = 10
b = a / 4
n_bfs = 100

dmp1 = DMP(T, dt, n_bfs=n_bfs, a=a, b=b)
dmp1.fit(path1)

dmp2 = DMP(T, dt, n_bfs=n_bfs, a=a, b=b)
dmp2.fit(path2)
# run
y1 = np.zeros(dmp1.cs.N)
y2 = np.zeros(dmp1.cs.N)

k = 1.3
for i in range(dmp1.cs.N):
    y1[i], _, _, _ = dmp1.step(k=k)
    y2[i], _, _, _ = dmp2.step(k=k)

# plot
plt.figure(figsize=(6, 6))

plt.plot(path1, path2, label="Reference trajectory")
plt.plot(y1, y2, label="DMP trajectory")

plt.axis('equal')
plt.xlim([path1.min()*2, path1.max()*2])
plt.ylim([path2.min()*2, path2.max()*2])
plt.legend()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2029598308668076, 'fraction_numerical': 0.05391120507399577, 'mean_word_length': 4.636904761904762, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '639448', 'license': 'MIT', 'n_tokens_mistral': 506, 'n_tokens_neox': 477, 'n_words': 90, 'path': 'notebooks/Draw Number.ipynb', 'repo_name': 'tsitsimis/dmpling', 'size': '946'}