Commit 70a37ce3 authored by Fredrik Bagge Carlson's avatar Fredrik Bagge Carlson
Browse files

Added memory to output so that one can get different sequences

parent 4f358ed6
...@@ -32,7 +32,16 @@ function sobol(dim::Int64, N::Int64) ...@@ -32,7 +32,16 @@ function sobol(dim::Int64, N::Int64)
X[j,:], nextseed, MeM = getNewSobolVector(dim, nextseed, MeM) X[j,:], nextseed, MeM = getNewSobolVector(dim, nextseed, MeM)
end end
return X return X, nextseed, MeM
end
function sobol(X, nextseed, MeM)
(N,dim) = size(X)
for j = 1:N
X[j,:], nextseed, MeM = getNewSobolVector(dim, nextseed, MeM)
end
return X, nextseed, MeM
end end
## Functions below are inner functions, I have not determined if this is needed, the fastest method or anything else ## Functions below are inner functions, I have not determined if this is needed, the fastest method or anything else
...@@ -106,7 +115,7 @@ end ...@@ -106,7 +115,7 @@ end
function InitSobol(dim::Int64) function InitSobol(dim::Int64)
MeM = Mem(dim) MeM = Mem(dim)
MeM.seed_save = -1 MeM.seed_save = -1
# MeM.v = zeros(40,30) # done in constructor instead # MeM.v = zeros(40,30) # done in constructor instead
MeM.v[1:40,1] = 1 MeM.v[1:40,1] = 1
MeM.v[3:40,2] = [1, 3, 1, 3, 1, 3, 3, 1, MeM.v[3:40,2] = [1, 3, 1, 3, 1, 3, 3, 1,
...@@ -188,4 +197,22 @@ function InitSobol(dim::Int64) ...@@ -188,4 +197,22 @@ function InitSobol(dim::Int64)
return MeM return MeM
end end
"""
`using Winston`
Plots the first 4 outputs of sobel(2,512)
"""
function test_sobol()
X, nextseed, MeM = sobol(2,512)
figure(); pp = plot(X[:,1],X[:,2],".b"); hold(true)
X, nextseed, MeM = sobol(X, nextseed, MeM )
plot(X[:,1],X[:,2],".g")
X, nextseed, MeM = sobol(X, nextseed, MeM )
plot(X[:,1],X[:,2],".r")
X, nextseed, MeM = sobol(X, nextseed, MeM )
plot(X[:,1],X[:,2],".m")
display(pp)
end
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment