Generalize TransferOperator
First draft PR. I tried to follow the design ideas mentioned here #424 .
TransferOperator becomes a ProbabilitiesEstimator.
TransferOperator <: ProbabilitiesEstimator #true
First results:
x = [1.0,2.0,1.0,2.0,1.0] #simple dummy time series
#1D counting-based outcome spaces
op = OrdinalPatterns{2}()
vb = ValueBinning(RectangularBinning(5))
d = Dispersion(; c = 3, m = 2, τ = 1)
ue = UniqueElements()
#try with different outcome spaces
transferoperator(op,x)
transferoperator(vb,x)
transferoperator(d,x)
transferoperator(ue,x)
which returns a TransferOperatorApproximation <: ProbabilitiesEstimator .
OP example:
codify(op,x)
4-element Vector{Int64}:
1
2
1
2
to = transferoperator(op,x)
to.outcome_space #gives back op
OrdinalPatterns{2}, with 2 fields:
encoding = OrdinalPatternEncoding(perm = [2, 1], lt = isless_rand)
τ = 1
to.outcomes #unique outcomes
2-element Vector{Int64}:
1
2
Most important field is the transfermatrix
to.transfermatrix
2×2 SparseMatrixCSC{Float64, Int64} with 2 stored entries:
⋅ 1.0
1.0 ⋅
probabilities function does work formally in that it gives an output:
probabilities(TransferOperator(),op,x)
Probabilities{Float64,1} over 2 outcomes
Outcome(1) 0.6056021883538506
Outcome(2) 0.3943978116461494
but for some reason, for this particular example, the iterative method used in invariant_measure does not converge.
probabilities(TransferOperator(),op,x;N=4000,tolerance=1e-12) #keyword args are propagated to invariant_measure
Probabilities{Float64,1} over 2 outcomes
Outcome(1) 0.9508731468636822
Outcome(2) 0.04912685313631784
the correct probabs of course would be [0.5,0.5] as the eigenvector corresponding to eigenvalue 1 is [1,1]. This might be a separate issue though.
Let me know what you think.
is there any paper in the literature that has generalized the transfer operator like this? Among other outcome spaces? if not, perhaps you can consider making this a paper.
is there any paper in the literature that has generalized the transfer operator like this? Among other outcome spaces? if not, perhaps you can consider making this a paper.
At least I am not aware of any such paper. Would be a cool contribution for sure!
@rusandris Thanks for the PR! I am super busy at the moment, so I'm not able to review this in detail yet. I'll try to get to it within the next couple of weeks.
the correct probabs of course would be [0.5,0.5] as the eigenvector corresponding to eigenvalue 1 is [1,1]. This might be a separate issue though. Let me know what you think.
I'll have to do a thorough review dig deeper to understand this issue. I'll ping you when I've tested this out a bit, @rusandris.
is there any paper in the literature that has generalized the transfer operator like this? Among other outcome spaces? if not, perhaps you can consider making this a paper.
At least I am not aware of any such paper. Would be a cool contribution for sure!
Just to be clear: i have no capacity to be involved in such a paper, but it is worth discussing with your supervisor Andras.
I'll have to do a thorough review dig deeper to understand this issue. I'll ping you when I've tested this out a bit, @rusandris.
I looked inside invariant_measure to see what happens exactly.
Adding some @show statements
julia> probabilities(TransferOperator(),op,x;N=5,tolerance=1e-12)
distribution = [0.28892942757860407 0.7110705724213959]
distribution = [0.7110705724213959 0.28892942757860407]
distance = 0.7778172853930047
distribution = [0.28892942757860407 0.7110705724213959]
distance = 0.7778172853930047
distribution = [0.7110705724213959 0.28892942757860407]
distance = 0.7778172853930047
distribution = [0.28892942757860407 0.7110705724213959]
distance = 0.7778172853930047
distribution = [0.7110705724213959 0.28892942757860407]
distance = 0.7778172853930047
Probabilities{Float64,1} over 2 outcomes
Outcome(1) 0.7110705724213959
Outcome(2) 0.28892942757860407
reveals of course that it works as it should. Since the transition matrix looks like this
to.transfermatrix
2×2 SparseMatrixCSC{Float64, Int64} with 2 stored entries:
⋅ 1.0
1.0 ⋅
the iterative method keeps flipping the initial random values inside the distribution. This wouldn't converge, unless the initial distribution is already given as
probabilities(RelativeAmount(),op,x)
Probabilities{Float64,1} over 2 outcomes
Outcome(1) 0.5
Outcome(2) 0.5