-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new momentum-sampling strategy
Now supports sampling momentum with quasi-monte-carlo sequence (low-discrepancy sequence).
- Loading branch information
Showing
3 changed files
with
83 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using QuasiMonteCarlo, Distributions | ||
|
||
mutable struct Quasi_MC_seed | ||
array::AbstractVecOrMat{<:Real} | ||
counter::Int | ||
|
||
# Custom constructor with a default value for `counter` | ||
function Quasi_MC_seed(array::AbstractVecOrMat{<:Real}, counter::Int = 1) | ||
new(array, counter) | ||
end | ||
end | ||
|
||
function get_next_vector(q::Quasi_MC_seed; normalized = true) | ||
val = q.array[:, q.counter] | ||
q.counter += 1 | ||
if normalized | ||
return uniform_to_normal(val) | ||
else | ||
return val | ||
end | ||
end | ||
|
||
function uniform_to_normal(uniform_vector::Vector{Float64})::Vector{Float64} | ||
normal_dist = Normal(0, 1) | ||
return [quantile(normal_dist, u) for u in uniform_vector] | ||
end |