Skip to content

Commit 2b43072

Browse files
committed
Add storage of proposed jumps
1 parent c47ae4a commit 2b43072

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ReversibleJumpMCMC"
22
uuid = "4e599b9b-5231-4225-b353-2dfd54e54db8"
33
authors = ["Keith Lidke <klidke@unm.edu> and contributors"]
4-
version = "0.1.0"
4+
version = "0.1.1"
55

66
[deps]
77
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"

src/ReversibleJumpMCMC.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Contains information about the chain including a vector of accepted states
4343
- `jumptypes::Vector{Int32} : vector of the attempted jumptype from the current state
4444
- `α::Vector{Float32} : vector of acceptance probabilities from proposed state
4545
- `accept::Vector{Bool} : vector of results from acceptance calculation
46+
- 'proposedstates::Vector{Any}' : vector of proposed states
4647
4748
"""
4849
mutable struct RJChain #this is the main output of RJMCMC
@@ -51,12 +52,14 @@ mutable struct RJChain #this is the main output of RJMCMC
5152
jumptypes::Vector{Int32}
5253
α::Vector{Float32}
5354
accept::Vector{Bool}
55+
proposedstates::Vector{Any}
5456
end
5557
RJChain(n::Int32)=RJChain(n,
5658
Vector{Any}(undef,n),
5759
zeros(Int32,n),
5860
Vector{Float32}(undef,n),
5961
Vector{Bool}(undef,n),
62+
Vector{Any}(undef,n)
6063
)
6164
function length(rjc::RJChain)
6265
return rjc.n
@@ -69,6 +72,7 @@ function initchain(rjs::RJMCMCStruct,burninchain::RJChain) #this gets last state
6972
newchain.accept[1]=1
7073
newchain.α[1]=1
7174
newchain.jumptypes[1]=0
75+
newchain.proposedstates[1]=burninchain.states[burninchain.n]
7276
return newchain
7377
end
7478

@@ -79,6 +83,7 @@ function initchain(rjs::RJMCMCStruct,intialstate) #this initializes new chain gi
7983
newchain.accept[1]=1
8084
newchain.α[1]=1
8185
newchain.jumptypes[1]=0
86+
newchain.proposedstates[1]=intialstate
8287
return newchain
8388
end
8489

@@ -125,7 +130,8 @@ function runchain!(rjs::RJMCMCStruct,rjc::RJChain,iterations,mhs)
125130

126131
#get proposal
127132
mtest,vararg=rjs.proposalfuns[jt](mhs,rjc.states[nn])
128-
133+
rjc.proposedstates[nn+1]=mtest;
134+
129135
#calculate acceptance probability
130136
α=rjs.acceptfuns[jt](mhs,rjc.states[nn],mtest,vararg)
131137
rjc.α[nn+1]=α;

0 commit comments

Comments
 (0)