Implement missing merge/merge! functions for AlgR and AlgL algorithms #128
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the missing
mergeandmerge!functions for the unweighted sampling algorithmsAlgRandAlgL, which were previously throwing "To Be Implemented" errors.Changes Made
Core Implementation
get_psfunctions forMultiAlgRSamplerandMultiAlgLSamplerthat calculate probabilities based onseen_kvaluesreduce_samples_hypergeometricfunction that uses the hypergeometric distribution for proper unweighted sampling without replacement, as required for these algorithmsBase.mergefunctions for bothMultiAlgRSamplerandMultiAlgLSamplerthat create new merged samplersBase.merge!functions for both algorithms that update the first sampler in-placeKey Features
AlgLsamplers (resetsstateandskip_kto 0)Testing
AlgRandAlgLalgorithmsmergeandmerge!functionsExample Usage
This implementation completes the merge functionality for all unweighted reservoir sampling algorithms in the package.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/FluxML/MacroTools.jl/tarball/1e0228a030642014fe5cfe68c2c0a818f9e3f522julia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaArrays/FillArrays.jl/tarball/6a70198746448456524cb442b8af316927ff3e1ajulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaBinaryWrappers/OpenSpecFun_jll.jl/tarball/1346c9208249809840c91b26703912dff463d335julia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaBinaryWrappers/Rmath_jll.jl/tarball/58cdd8fb2201a6267e1db87ff148dd6c1dbd8ad8julia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaCI/BenchmarkTools.jl/tarball/e38fbc49a620f5d0b660d7f543db1009fe0f8336julia --project=test -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaCollections/AbstractTrees.jl/tarball/2d9c9a55f9c93e8887ad391fbae72f8ef55e1177julia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaCollections/DataStructures.jl/tarball/4e1fe97fdaed23e9dc21d4d664bea76b65fc50a0julia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaCollections/DataStructures.jl/tarball/76b3b7c3925d943edf158ddb7f693ba54eb297a5julia --project=test -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaCollections/OrderedCollections.jl/tarball/05868e21324cede2207c6f0f466b4bfef6d5e7eejulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaCollections/SortingAlgorithms.jl/tarball/64d974c2e6fdf07f8155b5b2ca2ffa9069b608d9julia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaData/DataAPI.jl/tarball/abe83f3a2f1b857aac70ef8b269080af17764bbejulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaData/Missings.jl/tarball/ec4f7fbeab05d7747bdf98eb74d130a2a2ed298djulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaData/Parsers.jl/tarball/7d2f8f21da5db6a806faf7b9b292296da42b2810julia --project=test -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaDocs/DocStringExtensions.jl/tarball/7442a5dfe1ebb773c29cc2962a8980f47221d76cjulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaFunctional/CompositionsBase.jl/tarball/802bb88cd69dfd1509f6670416bd4434015693adjulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaIO/JSON.jl/tarball/31e996f0a15c7b280ba9f76636b3ff9e2ae58c9ajulia --project=test -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaLang/Compat.jl/tarball/0037835448781bb46feb39866934e243886d756ajulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaLang/PrecompileTools.jl/tarball/5aa36f7049a63a1528fe8f7c3f2113413ffd4e1fjulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaMath/Combinatorics.jl/tarball/8010b6bb3388abe68d95743dcbea77650bb2eddfjulia --project=test -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaMath/HypergeometricFunctions.jl/tarball/68c173f4f449de5b438ee67ed0c9c748dc31a2ecjulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaMath/InverseFunctions.jl/tarball/a779299d77cd080bf77b97535acecd73e1c5e5cbjulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaMath/IrrationalConstants.jl/tarball/e2222959fbc6c19554dc15174c81bf7bf3aa691cjulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaMath/QuadGK.jl/tarball/9da16da70037ba9d701192e27befedefb91ec284julia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaMath/Roots.jl/tarball/8a433b1ede5e9be9a7ba5b1cc6698daa8d718f1djulia --project=test -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaMath/SpecialFunctions.jl/tarball/41852b8679f78c8d8961eeadc8f62cef861a52e3julia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaObjects/Accessors.jl/tarball/3b86719127f50670efe356bc11073d84b4ed7a5djulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaObjects/ConstructionBase.jl/tarball/b4b092499347b18a015186eae3042f72267106cbjulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaPackaging/JLLWrappers.jl/tarball/0533e564aae234aff59ab625543145446d8b6ec2julia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaPackaging/Preferences.jl/tarball/0f27480397253da18fe2c12a4ba4eb9eb208bf3djulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaRandom/StableRNGs.jl/tarball/95af145932c2ed859b63329952ce8d633719f091julia --project=test -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaStats/Distributions.jl/tarball/3e6d038b77f22791b8e3472b7c633acea1ecac06julia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaStats/HypothesisTests.jl/tarball/15319d5a767eb386bc4b702d5e025a0be62be293julia --project=test -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaStats/LogExpFunctions.jl/tarball/13ca9e2586b89836fd20cccf56e57e2b9ae7f38fjulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaStats/PDMats.jl/tarball/f07c06228a1c670ae4c87d1276b92c7c597fdda0julia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaStats/Rmath.jl/tarball/852bd0f55565a9e973fcfee83a84413270224dc4julia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaStats/Statistics.jl/tarball/ae3bb1eb3bba077cd276bc5cfc337cc65c3075c0julia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaStats/StatsAPI.jl/tarball/9d72a13a3f4dd3795a195ac5a44d7d6ff5f552ffjulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaStats/StatsBase.jl/tarball/2c962245732371acd51700dbb268af311bddd719julia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaStats/StatsFuns.jl/tarball/8e45cecc66f3b42633b8ce14d431e8e57a3e242ejulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/JuliaTesting/Aqua.jl/tarball/d57fd255a8932b6509baf43284c416fc44d0b903julia --project=test -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/LilithHafner/AliasTables.jl/tarball/9876e1e164b144ca45e9e3198d0b689cadfed9ffjulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/LilithHafner/PtrArrays.jl/tarball/1d36ef11a9aaf1e8b74dacc6a731dd1de8fd493djulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/SciML/CommonSolve.jl/tarball/0eee5eb66b1cf62cd6ad1b460238e60e4b09400cjulia --project=test -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/Tortar/HybridStructs.jl/tarball/dd1f40c880a18c0a59103dec2df0ca7a3aeeb25ejulia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/joshday/OnlineStatsBase.jl/tarball/a5a5a68d079ce531b0220e99789e0c1c8c5ed215julia --project=. -e using Pkg; Pkg.instantiate()(http block)https://api.github.com/repos/simonster/Reexport.jl/tarball/45e428421666073eab6f2da5c9d310d99bb12f9bjulia --project=. -e using Pkg; Pkg.instantiate()(http block)pkg.julialang.orgjulia --project=. -e using Pkg; Pkg.instantiate()(dns block)julia --project=test -e using Pkg; Pkg.instantiate()(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.