From 6a36f7f9f87fd7206346a0a63109d2579d67aa0e Mon Sep 17 00:00:00 2001 From: dehann Date: Sat, 18 Sep 2021 14:20:59 -0400 Subject: [PATCH] more kwargs on prod, bump v0.5.8 --- Project.toml | 2 +- src/MSGibbs01.jl | 31 ++++++++++++++----------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Project.toml b/Project.toml index 0884b11..cf80c24 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/MSGibbs01.jl b/src/MSGibbs01.jl index c94bb52..c5c65f0 100644 --- a/src/MSGibbs01.jl +++ b/src/MSGibbs01.jl @@ -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 @@ -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"))