Skip to content

Commit

Permalink
export SqrtMeanInverse and inv_exp_map
Browse files Browse the repository at this point in the history
  • Loading branch information
jdtuck committed Nov 16, 2023
1 parent e1e8ada commit 7ca5731
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ S3method(predict,mlpcr)
S3method(predict,pcr)
S3method(summary,fdawarp)
export(SqrtMean)
export(SqrtMeanInverse)
export(SqrtMedian)
export(align_fPCA)
export(bootTB)
Expand All @@ -35,6 +36,7 @@ export(gam_to_v)
export(gauss_model)
export(gradient)
export(horizFPCA)
export(inv_exp_map)
export(invertGamma)
export(jointFPCA)
export(joint_gauss_model)
Expand Down
29 changes: 29 additions & 0 deletions R/geometry.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ l2_curvenorm <- function(psi, time=seq(0,1,length.out=ncol(psi))){
sqrt(trapz(time,apply(psi^2,2,sum)))
}

#' map square root of warping function to tangent space
#'
#'
#' @param Psi vector describing psi function at center of tangent space
#' @param psi vector describing psi function to map to tangent space
#'
#' @return A numeric array of the same length as the input array `psi` storing the
#' shooting vector of `psi`
#'
#' @keywords srvf alignment
#' @export
inv_exp_map<-function(Psi, psi){
theta <- acos(inner_product(Psi,psi))

Expand Down Expand Up @@ -67,6 +78,24 @@ randomGamma <- function(gam,num){
return(rgam)
}

#' SRVF transform of warping functions
#'
#' This function calculates the srvf of warping functions with corresponding
#' shooting vectors and finds the inverse of mean
#'
#' @param gam matrix (\eqn{N} x \eqn{M}) of \eqn{M} warping functions with \eqn{N} samples
#' @return `gamI` inverse of Karcher mean warping function
#'
#' @keywords srvf alignment
#' @references Srivastava, A., Wu, W., Kurtek, S., Klassen, E., Marron, J. S.,
#' May 2011. Registration of functional data using fisher-rao metric,
#' arXiv:1103.3817v2.
#' @references Tucker, J. D., Wu, W., Srivastava, A.,
#' Generative Models for Function Data using Phase and Amplitude Separation,
#' Computational Statistics and Data Analysis (2012), 10.1016/j.csda.2012.12.001.
#' @export
#' @examples
#' gamI <- SqrtMeanInverse(simu_warp$warping_functions)
SqrtMeanInverse <- function(gam){
TT = nrow(gam)
n = ncol(gam)
Expand Down
32 changes: 32 additions & 0 deletions man/SqrtMeanInverse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions man/inv_exp_map.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7ca5731

Please sign in to comment.