Skip to content

Commit f5da52c

Browse files
committed
add script to play with ising
1 parent fce95a3 commit f5da52c

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

test/ising.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# using Revise
2+
3+
import PartialRejectionSampling
4+
const PRS = PartialRejectionSampling
5+
6+
dims = [5, 5] # if > (14, 14) the display becomes all black, don't know why !
7+
periodic = false
8+
H, J = 0.0, 0.001
9+
10+
ising = PRS.Ising(dims, periodic, H, J)
11+
12+
println("\nPartial Rejection Sampling\n")
13+
14+
seed = -1
15+
16+
state, cnt = PRS.prs(ising; rng=seed)
17+
energy = PRS.energy(ising, state)
18+
println("Number of resampling steps:\n$cnt")
19+
println("Energy:\n$energy")
20+
PRS.plot(ising, state)
21+
22+
println("\nPerfect Gibbs sampler\n")
23+
24+
seed = -1
25+
26+
state, cnt = PRS.gibbs_perfect(ising; rng=seed)
27+
energy = PRS.energy(ising, state)
28+
println("Number of resampling steps:\n$cnt")
29+
println("Energy:\n$energy")
30+
PRS.plot(ising, state)
31+

test/runtests.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
using PartialRejectionSampling
21
using Test
2+
import PartialRejectionSampling
3+
const PRS = PartialRejectionSampling
4+
5+
# using Documenter
6+
# doctest(PartialRejectionSampling, fix=true)
37

48
@testset "PartialRejectionSampling.jl" begin
59
# Write your tests here.

0 commit comments

Comments
 (0)