Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SystemIdentification
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fredrik Bagge Carlson
SystemIdentification
Commits
02370aae
Commit
02370aae
authored
Sep 4, 2015
by
Fredrik Bagge Carlson
Browse files
Options
Downloads
Patches
Plain Diff
Updates to type defs and ar,arx methods
parent
cf53f92c
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/SystemIdentification.jl
+17
-8
17 additions, 8 deletions
src/SystemIdentification.jl
src/armax.jl
+8
-3
8 additions, 3 deletions
src/armax.jl
test/tests.jl
+3
-0
3 additions, 0 deletions
test/tests.jl
with
28 additions
and
11 deletions
src/SystemIdentification.jl
+
17
−
8
View file @
02370aae
...
...
@@ -11,10 +11,12 @@ FitStatistics,
FitResult
,
IdData
,
# Functions
ar
,
arx
,
getARregressor
,
getARXregressor
,
find_na
ar
,
arx
,
getARregressor
,
getARXregressor
,
find_na
,
toeplitz
,
kalman
## Fit Methods =================
:
LS
:
LS_reg
:
LM
## Types =======================
...
...
@@ -22,8 +24,8 @@ abstract Model
abstract
LinearModel
<:
Model
abstract
NonLinearModel
<:
Model
abstract
Network
<:
NonLinearModel
typealias
Polynom
Union
(
Real
,
Array
{
Real
,
1
})
typealias
PolynomMatrix
Union
(
Array
{
Polynom
,
1
},
Polynom
)
typealias
Polynom
{
T
<:
Real
}
Union
(
T
,
Array
{
T
,
1
})
typealias
PolynomMatrix
{
T
<:
Real
}
Union
(
Array
{
Polynom
,
1
},
Polynom
)
"""
...
...
@@ -32,7 +34,7 @@ typealias PolynomMatrix Union(Array{Polynom,1},Polynom)
`bias::Bool`
\n
`λ::Float64`
\n
"""
type
AR
<:
Model
type
AR
<:
Linear
Model
a
::
Polynom
na
::
Int
bias
::
Bool
...
...
@@ -47,7 +49,7 @@ end
`bias::Bool`
\n
`λ::Float64`
\n
"""
type
ARX
<:
Model
type
ARX
<:
Linear
Model
a
::
Polynom
b
::
PolynomMatrix
na
::
Int
...
...
@@ -68,14 +70,17 @@ type FitStatistics
RMS
::
Float64
FIT
::
Float64
AIC
::
Float64
FitStatistics
(
e
::
Vector
{
Float64
})
=
new
(
rms
(
e
),
fit
(
e
),
aic
(
e
))
FitStatistics
(
y
::
Vector
{
Float64
},
yh
::
Vector
{
Float64
}
,
d
)
=
new
(
rms
(
y
-
yh
),
fit
(
y
,
yh
),
aic
(
y
-
yh
,
d
))
end
type
FitResult
error
::
VecOrMat
{
Float64
}
fit
::
FitStatistics
method
::
Symbol
FitResult
(
error
::
VecOrMat
{
Float64
},
method
::
Symbol
)
=
new
(
error
,
FitStatistics
(
error
),
method
)
function
FitResult
(
y
,
yh
,
d
::
Int
,
method
::
Symbol
)
error
=
y
-
yh
new
(
error
,
FitStatistics
(
y
,
yh
,
d
),
method
)
end
end
type
IdData
...
...
@@ -87,7 +92,11 @@ type IdData
IdData
(
y
::
VecOrMat
{
Float64
},
u
::
VecOrMat
{
Float64
})
=
new
(
y
,
u
,
0
)
end
## Helper functions
rms
(
x
)
=
sqrt
(
mean
(
x
.^
2
))
sse
(
x
)
=
sum
(
x
.^
2
)
fit
(
y
,
yh
)
=
100
*
(
1
-
rms
(
y
-
yh
)
./
rms
(
y
-
mean
(
y
)));
aic
(
x
,
d
)
=
log
(
sse
(
x
))
+
2
d
/
length
(
x
)
include
(
"armax.jl"
)
include
(
"kalman.jl"
)
...
...
This diff is collapsed.
Click to expand it.
src/armax.jl
+
8
−
3
View file @
02370aae
...
...
@@ -9,7 +9,10 @@ function ar(y::Vector{Float64}, na; λ = 0, bias=false)
end
prediction
=
A
*
w
error
=
y_train
-
prediction
return
AR
(
w
,
na
,
bias
,
λ
),
FitResult
(
error
,
:
LS
)
model
=
AR
(
w
,
na
,
bias
,
λ
)
na
=
bias
?
na
+
1
:
na
result
=
FitResult
(
y_train
,
prediction
,
na
,
λ
>
0
?
(
:
LS_reg
)
:
(
:
LS
))
return
model
,
result
end
ar
(
iddata
::
IdData
,
na
;
λ
=
0
,
doplot
=
false
,
bias
=
false
)
=
ar
(
iddata
.
y
,
na
;
λ
=
0
,
bias
=
bias
)
...
...
@@ -24,8 +27,10 @@ function arx(y::Vector{Float64}, u::VecOrMat{Float64}, na, nb; λ = 0, doplot=fa
end
prediction
=
A
*
w
error
=
y_train
-
prediction
return
AR
(
w
,
na
,
bias
,
λ
),
FitResult
(
error
,
:
LS
)
model
=
AR
(
w
,
na
,
bias
,
λ
)
na
=
bias
?
na
+
1
:
na
result
=
FitResult
(
y_train
,
prediction
,
na
,
λ
>
0
?
(
:
LS_reg
)
:
(
:
LS
))
return
model
,
result
end
arx
(
iddata
::
IdData
,
na
,
nb
;
λ
=
0
,
bias
=
false
)
=
arx
(
iddata
.
y
,
iddata
.
u
,
na
,
nb
;
λ
=
0
,
bias
=
bias
)
...
...
This diff is collapsed.
Click to expand it.
test/tests.jl
+
3
−
0
View file @
02370aae
using
SystemIdentification
@assert
isa
(
1
,
Polynom
)
@assert
isa
(
1.0
,
Polynom
)
@assert
isa
([
1.0
;
1.0
],
Polynom
)
@assert
isa
(
1.0
,
PolynomMatrix
)
@assert
isa
(
1
,
PolynomMatrix
)
ar
(
collect
(
1
:
5.0
),
1
,
bias
=
true
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment