Univariate DLMs in Scala
-
discount factor
-
Superposition (define
+
operator forDLM
objects) -
filter
method -
forecast
method -
smooth
method -
backSample
method (see p. 114 of WH) -
Gibbs
object (for FFBS) -
Merge Model class with DLM class
object DLM {
abstract class Generic(F:Any,G:Any,V:Any,W:Any) {
type Obs
type ObsVar
type Prior
// Param is the posterior updates like in Param.scala
type Param
// This is the type of the state parameter (vector, matrix)
type State
def filter(y:List[Obs],init:Param,prior:Prior):List[Param]
def forecast(y:List[Obs],filt:List[Param],nAhead:Int=1):List[(Obs,ObsVar)]
def smooth(y:List[Obs],filt:List[Param]):List[(Obs,ObsVar)]
def backSample(y:List[Obs],filt:List[Param]):List[State]
}
}
- type unions?
type ~[A] = A=>Nothing
type V[U,T] = ~[ ~[U] with ~[T] ]
type ~~[A] = ~[~[A]]
type OR[T,U] = { type Lambda[X] = ~~[X] <:< (T V U) }
type OR[T,U] = {
type ~[A] = A=>Nothing
type V[U,T] = ~[ ~[U] with ~[T] ]
type ~~[A] = ~[~[A]]
type Lambda[X] = ~~[X] <:< (T V U)
}
def bla[T: (Int OR Double)#Lambda](x: T):Double = x match {
case x:Int => x.toDouble
case x:Double => x + 1
}
bla(10)
bla(11.1)
Or try this.