Commit 75bd8853 authored by Fredrik Bagge Carlson's avatar Fredrik Bagge Carlson
Browse files

Renaming of types to be consistent with Base

parent 624c5ecc
......@@ -8,8 +8,9 @@ ARX,
RBFARX,
FitStatistics,
FitResult,
IdData,
# Functions
ar,arx,getARRegressor,getARXRegressor,findNa
ar,arx,getARregressor,getARXregressor,find_na
## Fit Methods =================
:LS
......@@ -59,26 +60,26 @@ type RBFARX <: Network
normalized::Bool
end
type Fitstatistics
type FitStatistics
RMS::Float64
FIT::Float64
AIC::Float64
Fitstatistics(e::Vector{Float64}) = new(rms(e),fit(e),aic(e))
FitStatistics(e::Vector{Float64}) = new(rms(e),fit(e),aic(e))
end
type Fitresult
type FitResult
error::VecOrMat{Float64}
fit::Fitstatistics
fit::FitStatistics
method::Symbol
end
type Iddata
type IdData
y::VecOrMat{Float64}
u::VecOrMat{Float64}
Ts::Float64
Iddata(y::VecOrMat{Float64}) = new(y,[],0)
Iddata(y::VecOrMat{Float64} ,Ts::Float64) = new(y,[],Ts)
Iddata(y::VecOrMat{Float64}, u::VecOrMat{Float64}) = new(y,u,0)
IdData(y::VecOrMat{Float64}) = new(y,[],0)
IdData(y::VecOrMat{Float64} ,Ts::Float64) = new(y,[],Ts)
IdData(y::VecOrMat{Float64}, u::VecOrMat{Float64}) = new(y,u,0)
end
......
"""`ar(y, na; λ = 0, doplot=false, bias=false)`"""
function ar(y, na; λ = 0, doplot=false, bias=false)
function ar(y::Vector{Float64}, na; λ = 0, doplot=false, bias=false)
y_train, A = getARRegressor(y,na;bias=bias)
n_points = size(A,1)
if λ == 0
......@@ -18,10 +18,10 @@ function ar(y, na; λ = 0, doplot=false, bias=false)
end
return w, error
end
ar(iddata, na; λ = 0, doplot=false, bias=false) = ar(iddata.y, na; λ = 0, doplot=doplot, bias=bias)
ar(iddata::IdData, na; λ = 0, doplot=false, bias=false) = ar(iddata.y, na; λ = 0, doplot=doplot, bias=bias)
"""arx(y, u, na, nb; λ = 0, doplot=false, bias=false)"""
function arx(y, u, na, nb; λ = 0, doplot=false, bias=false)
function arx(y::Vector{Float64}, u::VecOrMat{Float64}, na, nb; λ = 0, doplot=false, bias=false)
y_train, A = getARXRegressor(y,u, na, nb; bias=bias)
n_points = size(A,1)
if λ == 0
......@@ -40,11 +40,11 @@ function arx(y, u, na, nb; λ = 0, doplot=false, bias=false)
end
return w, error
end
arx(iddata, na, nb; λ = 0, doplot=false, bias=false) = arx(iddata.y, iddata.u, na, nb; λ = 0, doplot=doplot, bias=bias)
arx(iddata::IdData, na, nb; λ = 0, doplot=false, bias=false) = arx(iddata.y, iddata.u, na, nb; λ = 0, doplot=doplot, bias=bias)
function getARRegressor(y,na;bias=false)
function getARregressor(y::Vector{Float64},na;bias=false)
A = toeplitz(y[na+1:end],y[na+1:-1:1])
y = copy(A[:,1])
A = A[:,2:end]
......@@ -54,9 +54,9 @@ function getARRegressor(y,na;bias=false)
end
return y,A
end
getARRegressor(iddata, na, bias=false) = getARXRegressor(iddatay, na, bias=bias)
getARregressor(iddata::IdData, na, bias=false) = getARXRegressor(iddata.y, na, bias=bias)
function getARXRegressor(y,u, na, nb; bias=false)
function getARXregressor(y::Vector{Float64},u::VecOrMat{Float64}, na, nb; bias=false)
assert(length(nb) == size(u,2))
@show m = max(na+1,maximum(nb))
@show n = length(y) - m+1
......@@ -75,11 +75,11 @@ function getARXRegressor(y,u, na, nb; bias=false)
end
return y,A
end
getARXRegressor(iddata, na, nb; bias=false) = getARXRegressor(iddatay,iddata.u, na, nb, bias=bias)
getARXregressor(iddata::IdData, na, nb; bias=false) = getARXRegressor(iddata.y,iddata.u, na, nb, bias=bias)
"""Plots the RMSE and AIC for model orders up to `n`. Useful for model selection"""
function findNa(y,n)
function find_na(y::Vector{Float64},n::Int)
error = zeros(n,2)
for i = 1:n
w,e = ar(y,i)
......
Supports Markdown
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