-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from TuringLang/resampling_rng
Add RNG to resampling methods
- Loading branch information
Showing
8 changed files
with
53 additions
and
43 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 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 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 |
---|---|---|
@@ -1,17 +1,16 @@ | ||
@testset "resampling.jl" begin | ||
D = [0.3, 0.4, 0.3] | ||
num_samples = Int(1e6) | ||
rng = Random.GLOBAL_RNG | ||
|
||
resSystematic = AdvancedPS.resample_systematic(D, num_samples ) | ||
resStratified = AdvancedPS.resample_stratified(D, num_samples ) | ||
resMultinomial= AdvancedPS.resample_multinomial(D, num_samples ) | ||
resResidual = AdvancedPS.resample_residual(D, num_samples ) | ||
AdvancedPS.resample(D) | ||
resSystematic2= AdvancedPS.resample(D, num_samples ) | ||
resSystematic = AdvancedPS.resample_systematic(rng, D, num_samples) | ||
resStratified = AdvancedPS.resample_stratified(rng, D, num_samples) | ||
resMultinomial= AdvancedPS.resample_multinomial(rng, D, num_samples) | ||
resResidual = AdvancedPS.resample_residual(rng, D, num_samples) | ||
AdvancedPS.resample_systematic(rng, D) | ||
|
||
@test sum(resSystematic .== 2) ≈ (num_samples * 0.4) atol=1e-3*num_samples | ||
@test sum(resSystematic2 .== 2) ≈ (num_samples * 0.4) atol=1e-3*num_samples | ||
@test sum(resStratified .== 2) ≈ (num_samples * 0.4) atol=1e-3*num_samples | ||
@test sum(resMultinomial .== 2) ≈ (num_samples * 0.4) atol=1e-2*num_samples | ||
@test sum(resResidual .== 2) ≈ (num_samples * 0.4) atol=1e-2*num_samples | ||
end | ||
end |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
using AdvancedPS | ||
using Libtask | ||
using Random | ||
using Test | ||
|
||
@testset "AdvancedPS.jl" begin | ||
|
487a943
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
487a943
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/36675
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: