// Parameters for simulated signal
n_samples = 5000
fs = 1000
burst_freq = 10
burst_starts = [0, 3000]
burst_seconds = 1
burst_samples = burst_seconds*fs
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Design burst kernel
burst_kernel_t = create_times(burst_seconds, fs)
burst_kernel = 2*np.sin(burst_kernel_t*2*np.pi*burst_freq)
// Generate random signal with bursts
times = create_times(n_samples/fs, fs)
sig = np.random.randn(n_samples)
for ind in burst_starts:
sig[ind:ind+burst_samples] += burst_kernel
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Plot example signal
After Change
// Set time and sampling rate
n_seconds_burst = 1
n_seconds_noise = 2
fs = 1000
// Create a times vector
times = create_times(n_seconds_burst + n_seconds_noise, fs)
// Simulate a signal component with an oscillation
components = {"sim_powerlaw" : {"exponent" : 0},
"sim_oscillation" : {"freq" : 10}}
s1 = sim_combined(n_seconds_burst, fs, components, [0.1, 1])
// Simulate a signal component with just noise
s2 = sim_powerlaw(n_seconds_noise, fs, 0, variance=0.1)
// Join signals together to approximate a "burst"
sig = np.append(s1, s2)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Plot example signal