Commit 9702b42f authored by Fredrik Bagge Carlson's avatar Fredrik Bagge Carlson
Browse files

updates

parent 6db679f2
......@@ -13,7 +13,7 @@ FitResult,
IdData,
# Functions
ar,arx,getARregressor,getARXregressor,find_na,
toeplitz, kalman, kalman_smoother, forward_kalman
toeplitz, kalman, kalman_smoother, forward_kalman, PCA
## Fit Methods =================
:LS
......@@ -26,8 +26,8 @@ abstract Model
abstract LinearModel <: Model
abstract NonLinearModel <: Model
abstract Network <: NonLinearModel
typealias Polynom{T<:Real} Union(Array{T,1} , T)
typealias PolynomMatrix{T} Union(Array{Polynom{T},1},Polynom{T}, T)
typealias Polynom{T<:Real} Union{Array{T,1} , T}
typealias PolynomMatrix{T} Union{Array{Polynom{T},1},Polynom{T}, T}
......
"""
`kalman(R1,R2,theta, y, A, P)`
One dimensional Kalman filter for parameter estimates
`kalman(R1,R2,theta, y, A, P)`
"""
function kalman(R1,R2,theta, y, A, P)
function kalman1(R1,R2,theta, y, A, P)
ATP = A'P
K = (P*A)/(R2+ATP*A)
P = P - (P*A*ATP)./(R2 + ATP*A) + R1
......@@ -12,6 +12,20 @@ function kalman(R1,R2,theta, y, A, P)
return theta, P, e, yp
end
"""
`kalman(R1,R2,R12,theta, y, A, P)`
General Kalman filter for parameter estimates
"""
function kalman(R1,R2,R12,theta, y, A, P)
ATP = A'P
K = (P*A+R12)/(R2+ATP*A)
P = P - (P*A+R12)/(R2 + ATP*A)*(ATP+R12') + R1
yp = (A'theta)[1]
e = y-yp
theta = theta + K*e
return theta, P, e, yp
end
function forward_kalman(y,A,R1,R2, P0)
......
......@@ -38,7 +38,7 @@ end
function Lcurve(normE, normX, λ)
plot(normE,normX,xscale=:log10,yscale=:log10,m=:o)
annotations = [(normE[i],normX[i],"λ=$(round(λ[i],4))") for i in 1:length(λ)]
annotations = [(normE[i],normX[i],"λ=$(round(λ[i],8))") for i in 1:length(λ)]
annotate!(annotations)
xlabel!("RMSE"); ylabel!("||k||"); title!("L-curve")
end
......@@ -130,7 +130,7 @@ function pf_aux_nn(xp, w, wnn, y, N, g_density, f)
for t = 2:T
xpT = xp[:,t-1]
f(xpT,t-1)
f(xpT,t-1) # This is now incorrect. particles should be propagated without noise in this step.
wT = copy(w[:,t-1])
lambda = g_density(y[t],xpT)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment