Skip to content

Commit

Permalink
Merge pull request #84 from JuliaRobotics/21Q3/api/prodkwargs
Browse files Browse the repository at this point in the history
more kwargs on prod, bump v0.5.8
  • Loading branch information
dehann committed Sep 18, 2021
2 parents 532596f + 6a36f7f commit aa399d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Expand Up @@ -2,7 +2,7 @@ name = "KernelDensityEstimate"
uuid = "2472808a-b354-52ea-a80e-1658a3c6056d"
keywords = ["NBP", "nonparametric", "kernel density", "functional products", "multiscale", "Gibbs sampling", "KDE"]
desc = "A modified version of the multiscale Gibbs product and KDE"
version = "0.5.7"
version = "0.5.8"

[deps]
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Expand Down
31 changes: 14 additions & 17 deletions src/MSGibbs01.jl
Expand Up @@ -633,17 +633,20 @@ function prodAppxMSGibbsS(npd0::BallTreeDensity,
getLambda::T4=(getEuclidLambda,),
glbs = makeEmptyGbGlb(),
addEntropy::Bool=true,
ndims::Int=maximum(Ndim.(trees)),
partialDimMask::AbstractVector{BitVector} = [ones(Int,ndims) .== 1 for i in 1:length(trees)]
ndims::Integer=maximum(Ndim.(trees)),
Ndens = length(trees), # of densities
Np = Npts(npd0), # of points to sample
maxNp = maximum([Np; Npts.(trees)]),
Nlevels = floor(Int,(log(Float64(maxNp))/log(2.0))+1.0), # how many levels to a balanced binary tree?
randU = rand(Int(Np*Ndens*(Niter+2)*Nlevels)),
randN = randn(Int(ndims*Np*(Nlevels+1))),
partialDimMask::AbstractVector{<:BitVector} = [ones(Int,ndims) .== 1 for i in 1:length(trees)],
) where {T1<:Tuple,T2<:Tuple,T3<:Tuple,T4<:Tuple}
#
#

# See Ihler,Sudderth,Freeman,&Willsky, "Efficient multiscale sampling from products
# of Gaussian mixtures", in Proc. Neural Information Processing Systems 2003
Ndens = length(trees) # of densities
# ndims = trees[1].bt.dims # of dimensions
Np = Npts(npd0) # of points to sample

# prepare stack manifold add and diff operations functions (manifolds must match dimension)
addopT = length(addop)!=ndims ? ([ (addop[1]) for i in 1:ndims]...,) : addop
Expand All @@ -657,21 +660,15 @@ function prodAppxMSGibbsS(npd0::BallTreeDensity,
points = zeros(ndims*Np)
#??plhs[1] = mxCreateNumericMatrix(Ndens, Np, mxUINT32_CLASS, mxREAL);
indices=ones(Int,Ndens, Np)
maxNp = Np
for tree in trees
if (maxNp < Npts(tree))
maxNp = Npts(tree)
end
end
# for tree in trees
# if (maxNp < Npts(tree))
# maxNp = Npts(tree)
# end
# end

# how many levels to a balanced binary tree?
Nlevels = floor(Int,(log(Float64(maxNp))/log(2.0))+1.0)

# Generate enough random numbers to get us through the rest of this
if true
randU = rand(Int(Np*Ndens*(Niter+2)*Nlevels))
randN = randn(Int(ndims*Np*(Nlevels+1)))
else
if false
# FIXME using DelimitedFiles
randU = vec(readdlm("randU.csv"))
randN = vec(readdlm("randN.csv"))
Expand Down

0 comments on commit aa399d3

Please sign in to comment.