Upload 3299_252_159.py
Browse files- 3299_252_159.py +44 -0
3299_252_159.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""3299.252.159
|
3 |
+
|
4 |
+
Automatically generated by Colab.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1pSA_TGFhZzS4NUOUu7b73-BDcUy0upCx
|
8 |
+
"""
|
9 |
+
|
10 |
+
import torch
|
11 |
+
import matplotlib.pyplot as plt
|
12 |
+
import numpy as np
|
13 |
+
|
14 |
+
# Parameters
|
15 |
+
sampling_rate = 1000 # Sampling rate (samples per second)
|
16 |
+
duration = 1 # Duration of the wave (seconds)
|
17 |
+
frequencies = [5, 10, 15] # Frequencies of the components (Hz)
|
18 |
+
amplitudes = [1, 0.5, 0.25] # Amplitudes of the components
|
19 |
+
phase_shifts = [0, np.pi / 4, np.pi / 2] # Phase shifts of the components
|
20 |
+
|
21 |
+
# Generate the time vector
|
22 |
+
time = torch.linspace(0, duration, int(sampling_rate * duration))
|
23 |
+
|
24 |
+
# Initialize the wave
|
25 |
+
wealthy_wave = torch.zeros_like(time)
|
26 |
+
|
27 |
+
# Combine multiple sine waves to create a "wealthy" pattern
|
28 |
+
for freq, amp, phase in zip(frequencies, amplitudes, phase_shifts):
|
29 |
+
wave = amp * torch.sin(2 * torch.pi * freq * time + phase)
|
30 |
+
wealthy_wave += wave
|
31 |
+
|
32 |
+
# Convert to numpy for easier plotting
|
33 |
+
time_np = time.numpy()
|
34 |
+
wealthy_wave_np = wealthy_wave.numpy()
|
35 |
+
|
36 |
+
# Plot the wave
|
37 |
+
plt.figure(figsize=(10, 5))
|
38 |
+
plt.plot(time_np, wealthy_wave_np, label='Perfect Wealthy Wave')
|
39 |
+
plt.title('.159 Perfect Wealthy Wave')
|
40 |
+
plt.xlabel('Time (s)')
|
41 |
+
plt.ylabel('Amplitude')
|
42 |
+
plt.legend()
|
43 |
+
plt.grid(True)
|
44 |
+
plt.show()
|