sig = np.random.randn(n_samples)
// Compute the FFT
fft_output = np.fft.fft(sig)
freqs = np.fft.fftfreq(len(sig), 1. / fs)
// Rotate spectrum and invert, zscore to normalize.
// Note: the delta exponent to be applied is divided by two, as
// the FFT output is in units of amplitude not power
fft_output_rot = rotate_powerlaw(freqs, fft_output, -exponent/2)
sig = zscore(np.real(np.fft.ifft(fft_output_rot)))
if f_range is not None:
sig = filter_signal(sig, fs, infer_passtype(f_range), f_range, **filter_kwargs)
After Change
filt_len = compute_filter_length(fs, pass_type,
*check_filter_definition(pass_type, f_range),
n_seconds=filter_kwargs.get("n_seconds", None),
n_cycles=filter_kwargs.get("n_cycles", 3))
n_samples = int(n_seconds * fs) + filt_len + 1
else:
n_samples = int(n_seconds * fs)
sig = _create_powerlaw(n_samples, fs, exponent)
if f_range is not None:
sig = filter_signal(sig, fs, infer_passtype(f_range), f_range,
remove_edges=True, **filter_kwargs)
// Drop the edges, that were compensated for, if not using IIR (using FIR)
if not filter_kwargs.get("filt_type", None) == "iir":
sig, _ = remove_nans(sig)
return sig