FIX: Fixing bugs and innacuracies in state-space inference.

This commit is contained in:
Alexander Grigorievskiy 2016-04-06 17:35:08 +03:00
parent 07d7c4cd84
commit c374311e84
2 changed files with 7 additions and 5 deletions

View file

@ -129,14 +129,14 @@ class sde_Exponential(Exponential):
""" """
self.variance.gradient = gradients[0] self.variance.gradient = gradients[0]
self.lengthscale.gradient = gradients[1] self.lengthscale.gradient = gradients[1] * 2.0
def sde(self): def sde(self):
""" """
Return the state space representation of the covariance. Return the state space representation of the covariance.
""" """
variance = float(self.variance.values) variance = float(self.variance.values)
lengthscale = float(self.lengthscale) lengthscale = float(self.lengthscale*2.0)
F = np.array(((-1.0/lengthscale,),)) F = np.array(((-1.0/lengthscale,),))
L = np.array(((1.0,),)) L = np.array(((1.0,),))

View file

@ -3237,6 +3237,7 @@ class ContDescrStateSpace(DescreteStateSpace):
AB = np.dot(AB, np.vstack((np.zeros((n,n)),np.eye(n)))) AB = np.dot(AB, np.vstack((np.zeros((n,n)),np.eye(n))))
Q_noise_1 = linalg.solve(AB[n:,:].T,AB[:n,:].T) Q_noise_1 = linalg.solve(AB[n:,:].T,AB[:n,:].T)
Q_noise_2 = P_inf - A.dot(P_inf).dot(A.T)
# The covariance matrix Q by matrix fraction decomposition <- # The covariance matrix Q by matrix fraction decomposition <-
if compute_derivatives: if compute_derivatives:
@ -3276,8 +3277,9 @@ class ContDescrStateSpace(DescreteStateSpace):
else: else:
dA = None dA = None
dQ = None dQ = None
Q_noise = Q_noise_1 Q_noise = Q_noise_2
# Innacuracies have been observed when Q_noise_1 was used.
#Q_noise = Q_noise_1 #Q_noise = Q_noise_1
# Return # Return
@ -3484,4 +3486,4 @@ def balance_ss_model(F,L,Qc,H,Pinf,P0,dF=None,dQc=None,dPinf=None,dP0=None):
# (F,L,Qc,H,Pinf,P0,dF,dQc,dPinf,dP0) # (F,L,Qc,H,Pinf,P0,dF,dQc,dPinf,dP0)
return bF, bL, bQc, bH, bPinf, bP0, bdF, bdQc, bdPinf, bdP0, T return bF, bL, bQc, bH, bPinf, bP0, bdF, bdQc, bdPinf, bdP0, T