-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fractal_pattern.py
More file actions
31 lines (25 loc) · 930 Bytes
/
test_fractal_pattern.py
File metadata and controls
31 lines (25 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import numpy as np
import matplotlib.pyplot as plt
def generate_rhythm_pattern(length, fractal_dimension=1.5):
t = np.linspace(0, 1, length)
pattern = np.zeros_like(t)
for i in range(1, int(length / 2)):
pattern += np.sin(2 * np.pi * (2 ** i) * t) / (i ** fractal_dimension)
return (pattern - pattern.min()) / (pattern.max() - pattern.min())
# Set the parameters
length = 1000
fractal_dimension = 1.5
# Generate the rhythm pattern
pattern = generate_rhythm_pattern(50, fractal_dimension)
# Create the plot
plt.figure(figsize=(12, 6))
plt.plot(np.linspace(0, 1, length), pattern, color='blue')
plt.title(f'Rhythm Pattern (Fractal Dimension: {fractal_dimension})')
plt.xlabel('Time')
plt.ylabel('Amplitude')
plt.grid(True, linestyle='--', alpha=0.7)
# Add a horizontal line at y=0.5 for reference
plt.axhline(y=0.5, color='red', linestyle='--', alpha=0.5)
# Show the plot
plt.tight_layout()
plt.show()