diff --git a/src/CommonUtils.jl b/src/CommonUtils.jl index f3e3412..764c6a5 100644 --- a/src/CommonUtils.jl +++ b/src/CommonUtils.jl @@ -60,21 +60,23 @@ function updateProductSample( dest::BallTreeDensity, manikde!(pts, manifolds) end -# Returns the covariance (square), not deviation -function calcCovarianceBasic(M::AbstractManifold, ptsArr::Vector{P}) where P - #TODO double check the maths,. it looks like its working at least for groups - μ = mean(M, ptsArr) - Xcs = vee.(Ref(M), Ref(μ), log.(Ref(M), Ref(μ), ptsArr)) - Σ = mean(Xcs .* transpose.(Xcs)) - @debug "calcCovarianceBasic" μ - @debug "calcCovarianceBasic" Σ - # TODO don't know what to do here so keeping as before, #FIXME it will break - # a change between this and previous is that a full covariance matrix is returned - msst = Σ - msst_ = 0 < sum(1e-10 .< msst) ? maximum(msst) : 1.0 - return msst_ +function Statistics.cov(mkd::ManifoldKernelDensity, args...; kwargs...) + cov(mkd.manifold, getPoints(mkd), args...; kwargs...) end +function Statistics.mean(mkd::ManifoldKernelDensity, args...; kwargs...) + return mean(mkd.manifold, getPoints(mkd), args...; kwargs...) +end + +function Statistics.std(mkd::ManifoldKernelDensity, args...; kwargs...) + return std(mkd.manifold, getPoints(mkd), args...; kwargs...) +end + +function Statistics.var(mkd::ManifoldKernelDensity, args...; kwargs...) + return var(mkd.manifold, getPoints(mkd), args...; kwargs...) +end + + """ $SIGNATURES diff --git a/src/Deprecated.jl b/src/Deprecated.jl index efae8e8..ac2a73b 100644 --- a/src/Deprecated.jl +++ b/src/Deprecated.jl @@ -7,6 +7,17 @@ @deprecate R(th::Real) _Rot.RotMatrix2(th).mat # = [[cos(th);-sin(th)]';[sin(th);cos(th)]']; @deprecate R(;x::Real=0.0,y::Real=0.0,z::Real=0.0) (M=SpecialOrthogonal(3);exp(M,identity_element(M),hat(M,Identity(M),[x,y,z]))) # convert(SO3, so3([x,y,z])) +export calcCovarianceBasic +# Returns the covariance (square), not deviation +function calcCovarianceBasic(M::AbstractManifold, ptsArr::Vector{P}) where P + @warn "`calcCovarianceBasic` is deprecated. Replace with IIF.calcSTDBasicSpread from IIF or `cov` or `var` from Manifolds. See issue AMP#150." + μ = mean(M, ptsArr) + Xcs = vee.(Ref(M), Ref(μ), log.(Ref(M), Ref(μ), ptsArr)) + Σ = mean(Xcs .* transpose.(Xcs)) + msst = Σ + msst_ = 0 < sum(1e-10 .< msst) ? maximum(msst) : 1.0 + return msst_ +end ## ====================================================================================================== ## Remove below before v0.7 diff --git a/src/ExportAPI.jl b/src/ExportAPI.jl index 3b31406..ea4a8df 100644 --- a/src/ExportAPI.jl +++ b/src/ExportAPI.jl @@ -19,7 +19,6 @@ export getKDEManifoldBandwidths, manifoldProduct, manikde!, - calcCovarianceBasic, isPartial, calcProductGaussians