Skip to content

Commit

Permalink
fix antimarginal for bistypes
Browse files Browse the repository at this point in the history
  • Loading branch information
Affie committed May 12, 2023
1 parent 5fe29e5 commit 22a8124
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function setPointPartial!(

end

#TODO workaround for supporting bitstypes, need rewrite, can consider `PowerManifoldNestedReplacing` or similar
#TODO workaround for supporting bitstypes, need rewrite, can consider `PowerManifoldNestedReplacing` or similar, maybe copyto!
function setPointsMani!(dest::AbstractArray{T}, src::AbstractArray{U}, destIdx, srcIdx=destIdx) where {T<:AbstractArray,U<:AbstractArray}
if isbitstype(T)
dest[destIdx] = src[srcIdx]
Expand Down
21 changes: 18 additions & 3 deletions src/services/ManifoldKernelDensity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,20 @@ end
# pts = getPoints(x)


"""
$SIGNATURES
If a marginal (statistics) of a probability reduce the dimensions (i.e. casts a shadow, or projects); then an
antimarginal aims to increase dimension of the probability within reason.
Notes
- Marginalization is a integration of for higher dimension to lower dimension, so antimarginal likely involve
differentiation (anti-integral) instead.
- In manifold language, this is an embedding into a higher dimensional space.
- See structure from motion in machine vision, or stereo disparity for building depth clouds from 2D images.
- Imagine combining three different partial embedding A=[1, nan, nan, 1.4], B=[nan,2.1,nan,4], C=[nan, nan, 3, nan]
which should equal A+B+C = [notnan, notnan, notnan, notnan]
"""
function antimarginal(newM::AbstractManifold,
u0,
mkd::ManifoldKernelDensity,
Expand All @@ -270,9 +283,10 @@ function antimarginal(newM::AbstractManifold,

# convert to antimarginal by copying user provided example point for bigger manifold
pts = getPoints(mkd, false)
nPts = Vector{typeof(u0)}(undef, length(pts))
for (i,pt) in enumerate(pts)
nPts[i] = setPointPartial!(newM, deepcopy(u0), mkd.manifold, pt, newpartial)
# new coord partials must be placed into a full dimension point, thats why we use u0
nPts = [deepcopy(u0) for _ in eachindex(pts)]
for i in eachindex(pts)
setPointPartial!(newM, nPts, mkd.manifold, pts, newpartial, i)
end

# also update metadata elements
Expand All @@ -286,6 +300,7 @@ function antimarginal(newM::AbstractManifold,
end



## =======================================================================================
## deprecate as necessary below
## =======================================================================================
Expand Down

0 comments on commit 22a8124

Please sign in to comment.