Commit a490a644 by Fredrik Bagge Carlson

### poked armax

parent b0371830
 ... ... @@ -7,19 +7,22 @@ function ar(y::Vector{Float64}, na; λ = 0, normtype=2, verbose=false) if normtype == 2 if λ == 0 w = A\y_train method = :LS else w = (A'A + λ*eye(size(A,2)))\A'y_train method = :LS_reg end elseif normtype == 1 w = Variable(size(A,2),1) problem = minimize(sum(abs(A*w-y_train )) + λ*norm(w)) solve!(problem, SCSSolver(verbose=Int(verbose))) w = w.value[:] method = :L1 end prediction = A*w error = y_train - prediction model = AR(w,na) result = FitResult(y_train,prediction,na, λ>0?(:LS_reg) :(:LS),λ) result = FitResult(y_train,prediction,na, method,λ) return model, result end ar(iddata::IdData, na; λ = 0) = ar(iddata.y, na; λ = 0) ... ... @@ -31,14 +34,17 @@ function arx(y::Vector{Float64}, u::VecOrMat{Float64}, na, nb; λ = 0, normtype= if normtype == 2 if λ == 0 w = A\y_train method = :LS else w = (A'A + λ*eye(size(A,2)))\A'y_train method = :LS_reg end elseif normtype == 1 w = Variable(size(A,2),1) problem = minimize(sum(abs(A*w-y_train )) + λ*norm(w)) solve!(problem, SCSSolver(verbose=Int(verbose))) w = w.value[:] method = :L1 end prediction = A*w error = y_train - prediction ... ... @@ -51,7 +57,7 @@ function arx(y::Vector{Float64}, u::VecOrMat{Float64}, na, nb; λ = 0, normtype= si += nb[i] end model = ARX(w[1:na],b,na,nb) result = FitResult(y_train,prediction,na, λ>0?(:LS_reg) :(:LS), λ) result = FitResult(y_train,prediction,na, method, λ) return model, result end arx(iddata::IdData, na, nb; λ = 0) = arx(iddata.y, iddata.u, na, nb; λ = 0) ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!