Skip to content

Commit

Permalink
Merge pull request #366 from JuliaRobotics/hotfix/3Q19/bssNaN
Browse files Browse the repository at this point in the history
prevent bss sampler from letting NaN through
  • Loading branch information
dehann authored Aug 5, 2019
2 parents 2522145 + 2a92650 commit a9be75c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/AliasScalarSampling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ struct AliasingScalarSampler
pxf = Float64.(p_x)
pxf[pxf.<0.0] .= 0.0 # no negative values!
pxf ./=sum(pxf) # must sum to 1
pxf .-= quantile(pxf,SNRfloor) # remove lowest quantile
pxf2 = pxf .- quantile(pxf,SNRfloor) # remove lowest quantile
pxf2s = sum(pxf2)
pxf[:] = 1e-10 < pxf2s ? pxf2 : pxf
pxf[pxf.<0.0] .= 0.0
pxf ./=sum(pxf)
pxf ./= sum(pxf)
sum(isnan.(pxf)) == 0 ? nothing : error("AliasingScalarSampler got NaN because of particular values in p_x")
wim = StatsBase.ProbabilityWeights(pxf)
new(x, wim)
end
Expand Down

0 comments on commit a9be75c

Please sign in to comment.