QuantEcon.jl
QuantEcon.jl copied to clipboard
MarkovChain: state_values
-
Add a method to set
state_values
afterwards
Oncemc
is created bymc = MarkovChain(p)
, then thestate_values
field has typeUnitRange
. Currently, it is not allowed to change it to, say, anArray
of state values. (This is relevant in particular forDPSolveResult.mc
.) -
Allow
state_values
to beAbstractArray
?
When state values are 2-dimensional for example, the state space may be represented by aMatrix
, but it is not accepted, because ofTV<:AbstractVector
wherestate_values::TV
.
In response to the first point, I would prefer to have the MarkovChain
type be immutable. Instead of changing the state values later on, I would encourage users to simply construct a new MarkovChain instance using the original transition matrix and supplying new state values.
I'd be open to allowing the state_values to be an AbstractArray, with the number of elements in the first dimension equaling the number of rows and columns of the transition matrix. We'd have to think carefully (and probably prototype) to make sure that things like simulation are still seamless/natural if we can't make the assumption of AbstractVector
anymore. An alternative to using Matrix{T}
you could use Vector{NTuple{N,T}}
where N
is the number of columns the Matrix would have. There are tradeoffs there too...