download
raw
718 Bytes
import numpy as np
import scipy.io
def generate_noise_temporal(time, tlength, q, vseed, is_matlab=True):
"""
Generates correlated noise
"""
nstep = len(time)
if is_matlab:
np.random.seed(vseed)
else:
# For octave compatibility, load state from mat file
mat = scipy.io.loadmat(f'randomstate_head/randomState{vseed}.mat')
np.random.set_state(mat['v'][0])
seed = np.random.randn(nstep)
# Correlation matrix
time_diff = time[:, np.newaxis] - time[np.newaxis, :]
Corr = np.exp(- (time_diff ** 2) / (tlength ** 2))
fpert = Corr @ seed
famp = np.sum(fpert ** 2) / nstep
fpert = fpert * np.sqrt(q / famp)
return fpert

Xet Storage Details

Size:
718 Bytes
·
Xet hash:
e1de34e83e8185041cb7c71b5c65d5ec59748f41bfc32b28787b1baf8aea009b

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.