-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
included test and code for halton sequence, can be used in diverse ps…
…eudo-random gen
- Loading branch information
1 parent
280b19c
commit dcbffe1
Showing
5 changed files
with
48 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
haltonnumber = BlackBoxOptim.Utils.haltonnumber | ||
haltonsequence = BlackBoxOptim.Utils.haltonsequence | ||
|
||
# The Halton sequence with base 2 according to http://en.wikipedia.org/wiki/Halton_sequence | ||
HaltonSequence2 = [ | ||
1/2, 1/4, 3/4, 1/8, 5/8, 3/8, 7/8, 1/16, 9/16 | ||
] | ||
|
||
# The Halton sequence with base 2 according to http://en.wikipedia.org/wiki/Halton_sequence | ||
HaltonSequence3 = [ | ||
1/3, 2/3, 1/9, 4/9, 7/9, 2/9, 5/9, 8/9, 1/27 | ||
] | ||
|
||
@testset "Halton numbers and sequence" begin | ||
|
||
@testset "Halton numbers" begin | ||
|
||
map(1:length(HaltonSequence2)) do i | ||
@test isapprox(haltonnumber(2, i), HaltonSequence2[i]) | ||
end | ||
|
||
map(1:length(HaltonSequence3)) do i | ||
@test isapprox(haltonnumber(3, i), HaltonSequence3[i]) | ||
end | ||
|
||
end | ||
|
||
@testset "Halton sequences" begin | ||
|
||
hseq2 = haltonsequence(2, length(HaltonSequence2)) | ||
@test length(hseq2) == length(HaltonSequence2) | ||
map(1:length(HaltonSequence2)) do i | ||
@test isapprox(hseq2[i], HaltonSequence2[i]) | ||
end | ||
|
||
hseq3 = haltonsequence(3, length(HaltonSequence3)) | ||
@test length(hseq3) == length(HaltonSequence3) | ||
map(1:length(HaltonSequence3)) do i | ||
@test isapprox(hseq3[i], HaltonSequence3[i]) | ||
end | ||
|
||
end | ||
|
||
end |