Skip to content

Commit

Permalink
Merge pull request #18 from lrennels/scaleseq
Browse files Browse the repository at this point in the history
Generalize scale_sobol_seq
  • Loading branch information
lrennels authored Apr 4, 2019
2 parents 2467b51 + b25b7ce commit 9464eb6
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,15 @@ end


"""
scale_sobol_seq!(sequence::AbstractArray{<:Number, N}, dists::AbstractArray{Distribution, N})
scale_sobol_seq!(sequence::AbstractArray{<:Number, N}, dists::AbstractArray{T, N})
Rescale a Sobol `sequence` of parameters from the 0-to-1 range to their corresponding
univeariate distributions `dists`.
"""
function scale_sobol_seq!(sequence::AbstractArray{<:Number, N1}, dists::AbstractArray{<:Distribution, N2}) where N1 where N2
function scale_sobol_seq!(sequence::AbstractArray{<:Number, N1}, dists::AbstractArray{T, N2}) where T where N1 where N2
D = length(dists) # number of parameters
for param in 1:D
dist = dists[param]
if !(typeof(dist) <: UnivariateDistribution)
error("Distribution must be a subtype of UnivariateDistribution")
end
sequence[:, [param, param + D]] = quantile.(dist, sequence[:, [param, param + D]])
end
end

0 comments on commit 9464eb6

Please sign in to comment.