示例#1
0
Fm = Fmat(m, -1, 1, tseq.dt)


def step(x, t, dt):
    assert dt == tseq.dt
    return x @ Fm.T


f = {'m': m, 'model': step, 'jacob': Fm, 'noise': 0}

# In the animation, it can sometimes/somewhat occur
# that the truth is outside 3*sigma !!!
# Yet this is not so implausible because sinusoidal_sample()
# yields (multivariate) uniform (random numbers) -- not Gaussian.
wnum = 25
X0 = RV(func=lambda N: sqrt(5) / 10 * sinusoidal_sample(m, wnum, N))


def yplot(y):
    lh = plt.plot(jj, y, 'g*', MarkerSize=8)[0]
    plt.pause(0.8)
    return lh


h = partial_direct_obs_setup(m, jj)
h['noise'] = 0.01
h['plot'] = yplot

other = {'name': os.path.relpath(__file__, 'mods/')}
setup = TwinSetup(f, h, tseq, X0, **other)
示例#2
0
################### Noise setup ###################
# Instead of sampling model noise from sinusoidal_sample(),
# we will replicate it below by a covariance matrix approach.
# But, for strict equivalence, one would have to use
# uniform (i.e. not Gaussian) random numbers.
wnumQ = 25
sample_filename = 'data/samples/LA_Q_wnum' + str(wnumQ) + '.npz'

try:
  # Load pre-generated
  L = np.load(sample_filename)['Left']
except FileNotFoundError:
  # First-time use
  print('Generating a sample from which to initialize experiments.')
  NQ        = 20000 # Must have NQ > (2*wnumQ+1)
  A         = sinusoidal_sample(m,wnumQ,NQ)
  A         = 1/10 * anom(A)[0] / sqrt(NQ)
  Q         = A.T @ A
  U,s,_     = tsvd(Q)
  L         = U*sqrt(s)
  np.savez(sample_filename, Left=L)

X0 = GaussRV(C=CovMat(sqrt(5)*L,'Left'))

################### Forward model ###################
damp = 0.98;
Fm = Fmat(m,-1,1,tseq.dt)
def step(x,t,dt):
  assert dt == tseq.dt
  return x @ Fm.T
示例#3
0
Fm = Fmat(Nx,c=-1,dx=1,dt=tseq.dt)
def step(x,t,dt):
  assert dt == tseq.dt
  return x @ Fm.T

Dyn = {
    'M'    : Nx,
    'model': step,
    'jacob': Fm,
    'noise': 0
    }

# In the animation, it can sometimes/somewhat occur
# that the truth is outside 3*sigma !!!
# Yet this is not so implausible because sinusoidal_sample()
# yields (multivariate) uniform (random numbers) -- not Gaussian.
wnum  = 25
X0 = RV(M=Nx, func = lambda N: sqrt(5)/10 * sinusoidal_sample(Nx,wnum,N))

Obs = partial_direct_Obs(Nx,jj)
Obs['noise'] = 0.01

HMM = HiddenMarkovModel(Dyn,Obs,tseq,X0,LP=LPs(jj))


####################
# Suggested tuning
####################
# config = EnKF('PertObs',N=100,infl=1.02)

示例#4
0
################### Noise setup ###################
# Instead of sampling model noise from sinusoidal_sample(),
# we will replicate it below by a covariance matrix approach.
# But, for strict equivalence, one would have to use
# uniform (i.e. not Gaussian) random numbers.
wnumQ = 25
sample_filename = 'data/samples/LA_Q_wnum' + str(wnumQ) + '.npz'

try:
    # Load pre-generated
    L = np.load(sample_filename)['Left']
except FileNotFoundError:
    # First-time use
    print('Generating a sample from which to initialize experiments.')
    NQ = 20000  # Must have NQ > (2*wnumQ+1)
    A = sinusoidal_sample(Nx, wnumQ, NQ)
    A = 1 / 10 * center(A)[0] / sqrt(NQ)
    Q = A.T @ A
    U, s, _ = tsvd(Q)
    L = U * sqrt(s)
    np.savez(sample_filename, Left=L)

X0 = GaussRV(C=CovMat(sqrt(5) * L, 'Left'))

################### Forward model ###################
damp = 0.98
Fm = Fmat(Nx, -1, 1, tseq.dt)


def step(x, t, dt):
    assert dt == tseq.dt