Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
MultilevelChainSampler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Luca Lenz
MultilevelChainSampler
Commits
946f2102
Commit
946f2102
authored
1 year ago
by
Luca Lenz
Browse files
Options
Downloads
Patches
Plain Diff
fixed bugs
parent
28f9d2da
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/MultilevelChainSampler.jl
+3
-1
3 additions, 1 deletion
src/MultilevelChainSampler.jl
src/algos/christen_fox.jl
+1
-1
1 addition, 1 deletion
src/algos/christen_fox.jl
src/chains/all.jl
+0
-53
0 additions, 53 deletions
src/chains/all.jl
test/test_chains.jl
+8
-2
8 additions, 2 deletions
test/test_chains.jl
with
12 additions
and
57 deletions
src/MultilevelChainSampler.jl
+
3
−
1
View file @
946f2102
...
...
@@ -26,7 +26,9 @@ export sample
export
MetropolisHastings
,
ChristenFox
export
total_costs
export
nchains
,
info
,
states
export
nchains
,
info
export
is_multilevel
export
states
export
autocov
,
logpart
,
empirical_cdf
export
RejectionChains
...
...
This diff is collapsed.
Click to expand it.
src/algos/christen_fox.jl
+
1
−
1
View file @
946f2102
...
...
@@ -41,7 +41,7 @@ function AbstractMCMC.samples(sample, model::AbstractMultilevelModel, ::Christen
return
(;
rejections
=
[
zeros
(
Int
,
length
(
model
))],
transitions
=
[
sample
[
2
:
end
]],
last_accepted
=
Ptr
{
Int
}(
0
)
last_accepted
=
Ref
{
Int
}(
0
)
)
end
function
AbstractMCMC.save!!
(
samples
,
sample
,
::
Integer
,
model
::
AbstractMultilevelModel
,
::
ChristenFox
{
true
,
P
};
kwargs
...
)
where
{
P
}
...
...
This diff is collapsed.
Click to expand it.
src/chains/all.jl
+
0
−
53
View file @
946f2102
...
...
@@ -28,56 +28,3 @@ function Base.display(c::AbstractRejectionChains)
end
end
#=abstract type AbstractRejectionChains <: AbstractMCMC.AbstractChains end
#include("simple.jl")
#include("multi.jl")
#=
struct RejectionChains{X, L, R, I} <: AbstractRejectionChains
states::Matrix{X}
logprobs::Matrix{L}
rejections::Matrix{R}
end
eltype(c::RejectionChains{X,L,R}) where {X,L,R} = X
size(c::RejectionChains, args...) = size(c.states, args...)
function getindex(c::RejectionChains, n, m )
return RejectionChains(
c.states[n, m],
c.logprobs[n, m],
c.rejections[n, m]
)
end
function states(c::RejectionChains)
return fill.(c.states, c.rejections)
end
function get_info(c::RejectionChains)
s = size(c)
rejection_rate
(; )
end
=#
function Base.show(io::IO, c::RejectionBasedChains)
print(io, "Chain ", size(c), " {", eltype(c), "}")
end
function Base.display(c::RejectionBasedChains)
println(c)
info = get_info(c)
nchains = size(c, 2)
for k = keys(info)
if nchains == 1
println(" ", k, " : ", info[k][1])
else
m, s = mean(info[k]), std(info[k])
println(" ", k, " : ", m, " ± ", s)
end
end
end
=#
\ No newline at end of file
This diff is collapsed.
Click to expand it.
test/test_chains.jl
+
8
−
2
View file @
946f2102
...
...
@@ -9,16 +9,22 @@ using Revise
using
MultilevelChainSampler
using
CSV
,
DataFrames
w
=
CyclicWalk
()
s
=
MetropolisHastings
(
w
)
f
=
LogDensity
(
x
->-
x
^
2
/
2
)
c
=
sample
(
f
,
s
,
MCMCSerial
(),
1
00
,
4
)
c
=
sample
(
f
,
s
,
MCMCSerial
(),
3
00
,
4
)
# Test conversion
df
=
convert
(
Vector
{
DataFrame
},
c
)
c2
=
convert
(
RejectionChains
,
df
)
# Test
autocov
(
c
)
# Test multilevel
@test
all
(
abs
.
(
empirical_cdf
(
c
,
.
5
)
.-
0.78045
)
.<
0.1
)
g
=
MultilevelLogDensity
([
f
,
f
])
s3
=
ChristenFox
(
w
,
true
)
c3
=
sample
(
g
,
s3
,
MCMCSerial
(),
300
,
4
)
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