ElasticFDA.align_fPCA
— MethodAligns a collection of functions while extracting principal components. The functions are aligned to the principal components
align_fPCA(f, timet; num_comp=3, smooth=false, sparam=10, MaxItr=50)
:param f: array of shape (M,N) of N functions with M samples
:param timet: vector of size M describing the sample points
:param num_comp: Number of components (default = 3)
:param smooth: Smooth the data using a box filter (default = false)
:param sparam: Number of times to run smoothing filter (default 10)
:param MaxItr: Maximum number of iterations
Returns Dict containing
:return fn: aligned functions - array of shape (M,N) of N functions with M
samples
:return qn: aligned srvfs - similar structure to fn
:return q0: original srvf - similar structure to fn
:return mqn: srvf mean or median - vector of length M
:return gam: warping functions - similar structure to fn
:return q_pca: srsf principal directions
:return f_pca: functional principal directions
:return latent: latent values
:return coef: coefficients
:return U: eigenvectors
:return orig_var: Original Variance of Functions
:return amp_var: Amplitude Variance
:return phase_var: Phase Variance
ElasticFDA.bs
— FunctionCompute B-Spline basis bs(x, df, norder, nderiv=0) :param x: time samples :param df: degree of freedom :param norder: order of splines :param nderiv: derivative number
ElasticFDA.calc_shape_dist
— MethodCalculate elastic shape distance between two curves beta1 and beta2
calc_shape_dist(beta1, beta2)
:param beta1: array (n,T)
:param beta2: array (n,T)
:param method: optimization method to find warping, default is
Dynamic Programming ("DP"). Other options are
Coordinate Descent ("DP2"), Riemannian BFGS
("RBFGS")
:param wscale: with scale (false)
ElasticFDA.curve_geodesic
— FunctionForm geodesic between two curves
curve_geodesic(beta1::Array{Float64,2}, beta2::Array{Float64,2}, k::Integer=5)
:param beta1: array (n,T)
:param beta2: array (n,T)
:param k: number of curves along geodesic
:param wscale: with scale (false)
Returns
:return geod: curves along geodesic (n,T,k)
:return geod_q: srvf's along geodesic
ElasticFDA.curve_karcher_cov
— MethodCalculate Karcher Covariance of a set of curves
curve_karcher_cov(betamean, beta; mode='O')
:param betamean: array (n,T) of mean curve
:param beta: array (n,T,N) for N number of curves
:param mode: Open ('O') or Closed ('C') curves
:return K: covariance matrix
ElasticFDA.curve_karcher_mean
— MethodCalculates Karcher mean of a collection of curves using the elastic square-root velocity (srvf) framework.
curve_karcher_mean(beta; mode='O', maxit=20)
:param beta: array (n,T,N) for N number of curves
:param mode: Open ('O') or Closed ('C') curves
:param maxit: maximum number of iterations
:param wscale: with scale (false)
:return mu: mean srvf
:return betamean: mean curve
:return v: shooting vectors
:return q: array of srvfs
ElasticFDA.curve_pair_align
— MethodPairwise align two curves
curve_pair_align(beta1::Array{Float64,2}, beta2::Array{Float64,2})
:param beta1: array (n,T)
:param beta2: array (n,T)
Returns
:return beta2n: aligned curve 2 to 1
:return q2n: aligned srvf 2 to 1
:return gam: warping function
:return q1: srvf of curve 1
ElasticFDA.curve_principal_directions
— MethodCalculate principal directions of a set of curves
curve_principal_directions(betamean, mu, K; mode='O', no=3, N=5)
:param betamean: array (n,T) of mean curve
:param mu: array (n,T) of mean srvf
:param K: array (T,T) covariance matrix
:param mode: Open ('O') or Closed ('C') curve
:param no: number of components
:param N: number of samples on each side of mean
:return pd: array describing principal directions
ElasticFDA.curve_srvf_align
— MethodAligns a collection of curves using the elastic square-root velocity (srvf) framework.
curve_srvf_align(beta; mode='O', maxit=20)
:param beta: array (n,T,N) for N number of curves
:param mode: Open ('O') or Closed ('C') curves
:param maxit: maximum number of iterations
:return betan: aligned curves
:return qn: aligned srvfs
:return betamean: mean curve
:return q_mu: mean srvf
ElasticFDA.curve_to_q
— FunctionConvert curve to square-root velocity function (srvf)
curve_to_q(beta)
:param beta: array describing curve (n,T)
ElasticFDA.elastic_distance
— FunctionCalculate elastic distance between two functions
elastic_distance(f1::Vector, f2::Vector, timet::Vector,
method::AbstractString="SIMUL")
:param f1: vector of function 1 samples
:param f2: vector of function 2 samples
:param timet: vector of time samples
:param method: optimization method to find warping, default is
Dynamic Programming ("DP"). Other options are
Coordinate Descent ("DP2"), Riemannian BFGS
("RBFGS"), Simultaneous Alignment ("SIMUL")
:return da: amplitude distance
:return dp: phase distance
ElasticFDA.elastic_logistic
— MethodCalculate elastic logistic regression from function data f, for response y
elastic_logistic(f, y, timet; B=None, df=20, max_itr=20, smooth=false)
:param f: array (M,N) of N functions
:param y: vector (N) of responses
:param timet: vector (N) describing time samples
:param B: matrix describing basis functions (M,N) (default=None generates a
B-spline basis
:param df: degree of freedom of basis
:param max_itr: maximum number of iterations
:param smooth: smooth data
Returns Dict describing regression
:return alpha: intercept
:return beta: regression function
:return fn: aligned functions
:return qn: aligned srsfs
:return gamma: warping functions
:return q: original srsfs
:retrun B: basis functions
:return type: type of regressions
:return b: coefficients
:return LL: logistic loss
ElasticFDA.elastic_prediction
— MethodPrediction from elastic regression model
elastic_prediction(f, timet, model; y=None, smooth=false)
:param f: functions to predict
:param timet: vector describing time samples
:param model: calculated model (regression, musicologist, mlogistic)
:param y: true response (default = None)
:param smooth: smooth data (default = false)
Returns
:return y_pred: predicted value
:return y_labels: labels of predicted value
:return Perf: Performance metric if truth is supplied
ElasticFDA.elastic_regression
— MethodCalculate elastic regression from function data f, for response y
elastic_regression(f, y, timet; B=None, lambda=0, df=20, max_itr=20,
smooth=false)
:param f: array (M,N) of N functions
:param y: vector (N) of responses
:param timet: vector (N) describing time samples
:param B: matrix describing basis functions (M,N) (default=None generates a
B-spline basis
:param lambda: regularization parameter
:param df: degree of freedom of basis
:param max_itr: maximum number of iterations
:param smooth: smooth data
Returns Dict describing regression
:return alpha: intercept
:return beta: regression function
:return fn: aligned functions
:return qn: aligned srsfs
:return gamma: warping functions
:return q: original srsfs
:retrun B: basis functions
:return type: type of regressions
:return b: coefficients
:return SSE: sum of squared error
ElasticFDA.f_to_srsf
— FunctionConvert function to square-root slope function (srsf)
f_to_srsf(f::Array, timet=0, smooth=false)
:param f: array of shape (M,N) describing N functions of M samples
:param timet: vector describing time samples (default = 0) will generate
linearly spaced time vector of length M
:param smooth: smooth data (default = false)
ElasticFDA.gauss_model
— MethodComputes random samples of functions from aligned data using Gaussian model
gauss_model(warp_data; n=1, sort_samples=false)
:param warp_data: fdawarp type from srsf_align of aligned data
:param n: number of samples
:param sort_samples: sort samples
Returns warp_data containing
:return fs: random aligned functions
:return gams: random warping functions
:return ft: random functions
ElasticFDA.gradient
— Function1-D Gradient
gradient(a::Array, dx::Float64=1)
:param f: Vector
:param dx: stepsize
:return g: gradient
ElasticFDA.group_warping_bayes
— MethodGroup alignment of functions using Bayesian method
group_warping_bayes(f; iter=20000, times=5, powera=1)
:param f: array (M,N) of N functions
:param iter: number of MCMC iterations
:param times: time slicing
:param powera: MCMC parameter
Returns Dict containing
:return f_q: registered srvfs
:return gam_q: warping function
:return f_a: registered functions
:return gam: warping functions
ElasticFDA.horiz_fPCA
— MethodCalculates horizontal functional principal component analysis on aligned data
horiz_fPCA(warp_data; no=1)
:param warp_data: fdawarp type from srsf_align of aligned data
:param no: number of components to extract (default = 1)
Returns hfpca containing
:return gam_pca: warping principal directions
:return psi_pca: srsf functional principal directions
:return latent: latent values
:return U: eigenvectors
:return coef: scores
:return vec: shooting vectors
:return gam_mu: mean warping function
ElasticFDA.inverse_exp
— MethodCalculate shooting vector between two srvfs q1 and q2
inverse_exp(q1, q2, beta2)
:param q1: array (n,T)
:param q2: array (n,T)
:param beta2: array (n,T)
:return v: shooting vector
ElasticFDA.inverse_exp_coord
— MethodCalculate shooting vector and distance between two curves beta1 and beta2
inverse_exp_coord(beta1, beta2)
:param beta1: array (n,T)
:param beta2: array (n,T)
:param method: optimization method to find warping, default is
Dynamic Programming ("DP"). Other options are
Coordinate Descent ("DP2"), Riemannian BFGS
("RBFGS")
:param wscale: keep scale (false)
:return v: shooting vector
:return dist: shape distance
ElasticFDA.optimum_reparam
— FunctionCalculate optimum parameterization (warping of q2 to q1)
optimum_reparam(q1, timet, q2, lam=0.0, method="SIMUL", w=0.01, f1o=0.0,
f2o=0.0)
:param q1: array (M,N) or vector (M) describing srsf set 1
:param timet: vector describing time samples of length M
:param q2: array (M,N) or vector (M) describing srsf of set 2
:param lam: control amount of warping (default=0.0)
:param method: optimization method to find warping, default is
Dynamic Programming ("DP"). Other options are
Coordinate Descent ("DP2"), Riemannian BFGS
("RBFGS"), Simultaneous Alignment ("SIMUL")
:param w: Controls RBFGS (default = 0.01)
:param f1o: initial value of f1, vector or scalar depending on q1, defaults
to zero
:param f2o: initial value of f2, vector or scalar depending on q1, defaults
to zero
optimum_reparam(q1, time1, q2, time2, lam=0.0, method="DP", w=0.01, f1o=0.0,
f2o=0.0)
same as above, but different timing for q1 and q2
optimum_reparam(beta1, beta2, lam, method="DP", w=0.01, rotated=true,
isclosed=false)
:param beta1: array (n,T) describing curve 1
:param beta2: array (n,T) describing curve 2
:param lam: control amount of warping (default=0.0)
:param method: optimization method to find warping, default is
Dynamic Programming ("DP"). Other options are
Coordinate Descent ("DP2"), Riemanain BFGS
("RBFGS")
:param w: Controls RBFGS (default = 0.01)
:param rotated: calculate rotation (default = true)
:param isclosed: closed curve (default = false)
:return gam: warping function
:return R: rotation matrix
:return tau: seed value
ElasticFDA.pair_warping_bayes
— MethodCompute pair warping between two functions using Bayesian method
pair_warping_bayes(f1, f2; iter=15000, times=5, powera=1)
:param f1, f2: vectors describing functions
:param iter: number of iterations
:param times: MCMC parameter
:param powera: MCMC parameter
Returns Dict containing
:return f1:
:return f2_q: srsf registration
:return gam_q: warping function
:return f2a: registered f2
:return gam: warping function
:return dist_collect: distance
:return best_match: best match
ElasticFDA.pair_warping_expomap
— MethodCompute pair warping between two functions using Bayesian method
pair_warping_expomap(f1, f2, timet; iter=20000, burnin=min(5000,iter/2),
alpha0=0.1, beta0=0.1, pbetas=[0.5,0.05,0.005,0.0001],
probs=[0.1,0.1,0.7,0.1],propvar=1.0,
init_coef=zeros(20),npoints=200,extrainfo=false)
:param f1, f2: vectors describing functions
:param timet: vector describing timing
:param iter: number of MCMC iterations
:param burnin: number of MCMC burnin iterations
:param alpha0, beta0: IG parameters for prior of sigma1
:param pbetas: mixture ratios for pCN
:param probs: mixcture probabilities for zpCN
:param propvar: variance of proposal distribution
:param init_coef: initial g coefficients
:param npoits: number of sample points to use during alignment
:param extrainfo: T/F whether additional information is returned (accept, logl, gamma_mat, gamma_stats, xdist, ydist)
Returns mcmc struct containing
:return f2_warped: warped f2
:return gamma: warping function
:return g_coef: g_coeficients
:return sigma1: variance samples
:return accept: accept samples
:return logl: log-likelihood
:return gamma_mat: posterior warping function samples
:return gamma_stats: posterior warping function samples 95% credible intervals
:return xdist: phase distance of posterior warping functions
:return ydist: amplitude distance of posterior warping functions
ElasticFDA.project_curve
— MethodProject curve onto normal tangent space
project_curve(q)
:param q: array (n,T)
ElasticFDA.project_tangent
— MethodProject srvf onto tangent space
project_tangent(w, q, basis)
:param w: shooting vector
:param q: array (n,T)
:param basis: basis out of find_basis_normal
ElasticFDA.q_to_curve
— MethodConvert srvf to curve
q_to_curve(q)
:param q: array describing srvf (n,T)
ElasticFDA.resamplecurve
— FunctionResample curve
resamplecurve(x, N=100)
:param x: array describing curve (n,T)
:param N: Number of samples to re-sample curve, N usually is > T
ElasticFDA.rgam
— MethodGenerate random warping functions
rgam(N, sigma, num)
:param N: number of time points
:param sigma: standard deviation across samples
:param num: number of random warpings
ElasticFDA.sample_shapes
— MethodSample shapes from model
sample_shapes(mu, K; mode='O', no=3, numSamp=10)
:param mu: array (n,T) mean srvf
:param K: array (T,T) covariance matrix
:param mode: Open ('O') or Closed ('C') curves
:param no: number of principal components
:param numSamp: number of samples
:return samples: array (n,T,numSamp) of sample curves
ElasticFDA.smooth_data
— FunctionSmooth functional data using box filter
smooth_data(f::Array{Float64,1}, sparam=10)
:param sparam: Number of times to run filter (default = 10)
ElasticFDA.smooth_data!
— Functionsmooth_data!(f::Array{Float64,1}, sparam=10)
:param sparam: Number of times to run filter (default = 10)
ElasticFDA.smooth_data!
— FunctionSmooth functional data using box filter in place
smooth_data!(f::Array{Float64,2}, sparam=10)
ElasticFDA.srsf_align
— MethodAligns a collection of functions using the elastic square-root slope (srsf) framework.
srsf_align(f, timet; method="mean", smooth=false, sparam=10, lam=0.0,
optim="DP", MaxItr=20)
:param f: array of shape (M,N) of N functions with M samples
:param timet: vector of size M describing the sample points
:param method: (string) calculate Karcher Mean or Median
(options = "mean" or "median") (default="mean")
:param smooth: Smooth the data using a box filter (default = false)
:param sparam: Number of times to run smoothing filter (default 10)
:param lam: controls the elasticity (default = 0)
:param optim: optimization method to find warping, default is
Simultaneous Alignment ("SIMUL"). Other options are
Dynamic Programming ("DP2"), Riemannian BFGS
("RBFGS")
:param MaxItr: Maximum number of iterations
Returns fdawarp type containing
:return fn: aligned functions - array of shape (M,N) of N
functions with M samples
:return qn: aligned srsfs - similar structure to fn
:return q0: original srsfs - similar structure to fn
:return fmean: function mean or median - vector of length N
:return mqn: srvf mean or median - vector of length N
:return gam: warping functions - similar structure to fn
:return orig_var: Original Variance of Functions
:return amp_var: Amplitude Variance
:return phase_var: Phase Variance
ElasticFDA.srsf_to_f
— FunctionConvert square-root slope function (srsf) to f
srsf_to_f(q::Array, time, f0=0.0)
:param q: array of shape (M,N) describing N srsf of M samples
:param time: vector describing time samples of length M
:param f0: initial value of f
ElasticFDA.trapz
— FunctionTrapezoidal Integration
trapz(x, y, dim=1)
:param x: vector of time samples
:param y: array of response samples
:param dim: dimension along which to integrate
ElasticFDA.vert_fPCA
— MethodCalculates vertical functional principal component analysis on aligned data
vert_fPCA(warp_data, qn; no=1)
:param warp_data: fdawarp type from srsf_align of aligned data
:param no: number of components to extract (default = 1)
Returns vfpca type containing
:return q_pca: srsf principal directions
:return f_pca: functional principal directions
:return latent: latent values
:return coef: scores
:return U: eigenvectors
:return id: point used for f(0)
ElasticFDA.warp_f_gamma
— MethodWarp function by gamma
warp_f_gamma(time::Vector, f::Vector, gam::Vector)
:param time: describes time samples
:param f: describes function
:param gam: describes warping function
ElasticFDA.warp_q_gamma
— MethodWarp srsf by gamma
warp_q_gamma(time::Vector, q::Vector, gam::Vector)
:param time: describes time samples
:param q: describes srsf
:param gam: describes warping function
ElasticFDA.DP_mean
— FunctionCalculate mean function using Bayesian Dynamic Programming DP_mean(f, times=5) :param f: array (M,N) of N functions :param times: MCMC parameter number of times to split
Returns Dict containing
:return distmfamily: distance matrix
:return match_matrix: match_matrix
:return position: position
:return mu_5: mean function
:return rtmatrix: rtmatrix
:return sumdist: sum distance
:return qt_fitted: qt fitted matrix
:return esimator: estimator
:return estimator2: estimator2
:return regcurve: registered curves
ElasticFDA.Enorm
— MethodEnorm(x::Array{Complex{Float64},1})
ElasticFDA.Enorm
— MethodCalculate normal Energy on an Array
Enorm(x::Array{Float64,1})
ElasticFDA.approx
— MethodLinear interpolation
approx(xd, yd, xi)
:param xd: x samples
:param yd: response samples
:param xi: new x samples
ElasticFDA.arclength
— MethodCalculate arc-length parametrization of function
arclength(f::Vector)
ElasticFDA.calc_j
— MethodCalculate Jacobian of basis
calc_j(basis)
:param basis: array of (2) from find_basis_normal
ElasticFDA.calculate_variance
— MethodCalculate variance along curve
calculate_variance(beta)
:param beta: array (n, T)
ElasticFDA.calculatecentroid
— MethodCalculate centroid of curve
calculatecentroid(beta)
:param beta: array describing curve (n,T)
ElasticFDA.cumtrapz
— FunctionCumulative Trapezoidal Integration
cumtrapz(x, y, dim=1)
:param x: vector describing time samples
:param y: array describing response
:param dim: dimension to integrate over
ElasticFDA.cumtrapzmid
— MethodCumulative Trapezoidal Integration using midpoint
cumtrapzmid(x, y, c)
:param x: time samples
:param y: resposne samples
:param c: midpoint
:param mid: midpoint location
ElasticFDA.curve_zero_crossing
— MethodCalculate zero crossing for optimal regression between curves
ElasticFDA.dp_bayes
— MethodCalculate Dynamic Programming using Bayesian approach dp_bayes(q1, q1L, q2L, times, cut) :param q1: vector (N) :param q1L: vector (q1L) :param q2L: vector (q2L) :param times: MCMC parameter number of simulations :param cut: MCMC parameter number of cuts
:return MatchIn2: warping function
:return NDist: minimal distance
:return q2LL: re-parameterized q2L
ElasticFDA.elastic_mlogistic
— MethodCalculate elastic m-logistic regression from function data f, for response y
elastic_mlogistic(f, y, timet; B=None, df=20, max_itr=20, smooth=false)
:param f: array (M,N) of N functions
:param y: vector (N) of responses
:param timet: vector (N) describing time samples
:param B: matrix describing basis functions (M,N) (default=None generates a
B-spline basis
:param df: degree of freedom of basis
:param max_itr: maximum number of iterations
:param smooth: smooth data
Returns Dict describing regression
:return alpha: intercept
:return beta: regression function
:return fn: aligned functions
:return qn: aligned srsfs
:return gamma: warping functions
:return q: original srsfs
:retrun B: basis functions
:return type: type of regressions
:return b: coefficients
:return n_classes: number of classes
:return LL: logistic loss
ElasticFDA.extrema_1s
— MethodFind location of change of sign of srsf that is arclength parameterized
extrema_1s(t::Vector, q::Vector)
ElasticFDA.find_basis_normal
— MethodFind basis normal to srvf
find_basis_normal(q)
:param q: array (n, T)
ElasticFDA.find_best_rotation
— MethodFind best rotation between two srvfs
find_best_roation(q1,q2)
:param q1: array (n, T)
:param q2: array (n, T)
ElasticFDA.find_rotation_and_seed_q
— MethodFind best rotation and seed value between two srvfs, q1 and q2
find_rotation_and_seed_q(q1,q2)
:param q1: array (n,T)
:param q2: array (n,T)
:return q2new: rotated srvf
:return O_hat: rotation matrix
:return tau: seed value
ElasticFDA.find_rotation_seed_coord
— MethodFinds best rotation and seed value between two curves beta1, beta2
find_rotation_seed_coord(beta1,beta2)
:param beta1: array (n,T)
:param beta2: array (n,T)
:return beta2new: rotated curve
:return O_hat1: rotation matrix
:return tau: seed value
ElasticFDA.findkarcherinv
— FunctionFind Karcher inverse of warping functions
findkarcherinv(warps, times, roundi=false)
ElasticFDA.gradient2
— Function2-D Gradient
gradient2(a::Array, dx::Float64=1, dy::Float=1)
:param a: matrix
:param dx: stepsize
:param dy: stepsize
:return dxdu: derivatives along x
:return dydv: derivatives along y
ElasticFDA.gradient_spline
— FunctionCalculate gradient of function using B-splines
gradient_spline(timet::Vector, f, smooth=false)
:param: timet: Vector describing time samples
:param: f: Vector or Array (M,N) describing functions of M samples
:param: smooth: smooth data (default = false)
ElasticFDA.gram_schmidt
— MethodGram-Schmidt Orthogonalization of basis
gram_schmidt(basis)
:param basis: basis out of find_basis_normal
ElasticFDA.group_action_by_gamma
— MethodWarp srvf by gamma
group_action_by_gamma(q, gamma)
:param q: array (n,T)
:param gamma: vector (T)
ElasticFDA.group_action_by_gamma_coord
— MethodWarp curve f by gamma
group_action_by_gamma_coord(f, gamma)
:param f: array (n,T)
:param gamma: vector (T)
ElasticFDA.innerprod_q2
— MethodFind inner product between two srvfs, q1 and q2
innerprod_q2(q1, q2)
:param q1: array (n,T)
:param q2: array (n,T)
ElasticFDA.interp1_flat
— MethodLinear interpolation when response contains flat regions
interp1_flat(x, y, xx)
:param x: time samples
:param y: response samples
:param xx: new time samples
ElasticFDA.invert_gamma
— MethodInvert warping function
invert_gamma(gam)
:param gam: vector describing warping function
ElasticFDA.itermatch
— MethodMCMC iteration for group alignment
ElasticFDA.karcher_calc
— Methodkarcher mean calculation function karcher_calc(beta, q, betamean, mu; mode='O') :param beta: array (n,T) :param q: array (n,T) :param betamean: array (n,T) :param mu: array (n,T) :param mode: Open ('O') or Closed ('C') curves :param wscale: with scale ('false')
:return v: shooting vector
:return d: elastic distance
ElasticFDA.logistic_warp
— MethodCalculate warping for logistic regression
logistic_warp(beta, timet, q, y)
:param beta: regression function
:param timet: time samples
:param q: srsf
:param y: response
Returns
:return gamma: new gamma
ElasticFDA.logit_gradient!
— MethodCalculate gradient of logistic optimization in place
logit_gradient!(b, grad, X, y)
:param b: coefficients
:param grad: gradient
:param X: matrix
:param y: response
ElasticFDA.logit_hessian
— MethodCalculate Hessian of logistic optimization
logit_hessian(s, b, X, y)
:param s:
:param b: coefficients
:param X: matrix
:param y: response
ElasticFDA.logit_loss
— MethodCalculate logistic loss function
logit_loss(b, X, y)
:param b: coefficients
:param X: matrix
:param y: response
Returns
:return out: loss function
ElasticFDA.logit_optm
— MethodCalculate logistic optimization function
logit_optm(x::Vector, grad::Vector, Phi, y)
:param x: samples
:param grad: gradient
:param Phi: coefficient matrix
:param y: response
ElasticFDA.match_ext
— MethodFind matching between two extremas
match_ext(t1, ext1, d1, t2, ext2, d2)
ElasticFDA.meshgrid
— MethodCreates Rectangular Grid in 2-D space
meshgrid(a::LinRange,b::LinRange)
ElasticFDA.mlogit_gradient!
— MethodCalculate m-logistic elastic regression loss function gradient in place
mlogit_gradient!(b, grad, X, Y)
:param b: coefficients
:param grad: gradient
:param X: matrix
:param Y: response matrix
ElasticFDA.mlogit_loss
— MethodCalculate loss for m-logistic regression
mlogit_loss(b, X, Y)
:param b: coefficients
:param X: matrix
:param Y: response matrix
ElasticFDA.mlogit_optm
— MethodCalculate warping for m-logistic elastic regression
mlogit_optim(x, grad, Phi, Y)
:param x: sample
:param grad: gradient
:param Phi: matrix
:param Y: response matrix
ElasticFDA.mlogit_warp_grad
— MethodCalculate m-logistic warping using gradient method
mlogit_warp_grad(alpha, beta, timet, q, y; max_itr=8000, tol=1e-10,
delt=0.008, display=0)
:param alpha: intercept
:param beta: regression function
:param timet: vector describing time samples
:param q: srsf
:param y: response
:param max_itr: maximum number of iterations
:param tol: stopping tolerance
:param delt: gradient step size
:param display: display optimization iterations
ElasticFDA.mvnrand
— MethodMultivariate Normal random number generation
mvnrand(mu, C, n)
:param mu: mean vector
:param C: covariance matrix
:param n: number of samples
ElasticFDA.parallel_translate
— FunctionParallel translate srvf along tangent space
parallel_translate(w, q1, q2, basis, mode='O')
:param w: shooting vector
:param q1: array (n,T)
:param q2: array (n,T)
:param basis: basis out of find_basis_normal
:param mode: Open ('O') or Closed ('C') curves
ElasticFDA.phi
— MethodLogistic function
phi(t)
Returns
:return out: phi(t)
ElasticFDA.pre_proc_curve
— FunctionPre-processes curve by centering and projecting to tangent space
pre_proc_curve(beta, T=100)
:param beta: array (n,T)
:param T: number of re-sample points
:return betanew: re-sampled and centered curve
:return qnew: projected srvf
:return A: rotation matrix
ElasticFDA.psi
— MethodCalculate psi
psi(x,a,q)
:param x: array (n, T) of curve
:param a: vector (n) of centroid
:param q: array (n, T) of srvf
ElasticFDA.qtocurve
— FunctionBayesian qtocurve function
qtocurve(q, timet=0)
ElasticFDA.random_gamma
— MethodGenerates random warping functions based on gam
random_gamma(gam, num)
:param gam: array (M,N) describing warping functions
:param num: number of functions to generate
ElasticFDA.regression_warp
— MethodOptimization function to calculate warping for elastic regression
regression_warp(beta, timet, q, y, alpha)
:param beta: regression function
:param timet: vector describing time samples
:param q: vector describing srsf
:param y: response value
:param alpha: intercept
Returns
:return gamma_new: new gamma
ElasticFDA.rot_mat
— MethodFind rotation matrix for angle theta
rot_mat(theta)
ElasticFDA.scale_curve
— MethodScale curve to unit length
scale_curve(beta)
:param beta: array (n,T)
ElasticFDA.shift_f
— MethodShift curve f by tau
shift_f(f, tau)
:param f: array (n,T)
:param tau: scalar
ElasticFDA.simuiter
— MethodMCMC iteration for pairwise alignment
ElasticFDA.simul_align
— MethodSimultaneous alignment between two functions
simul_align(f1::Vector, f2::Vector)
ElasticFDA.simul_gam
— MethodCalculate warping from q2 to q2 from simultaneous warping
simul_gam(u, g1,g2,t,s1,s2,tt)
ElasticFDA.simul_reparam
— MethodFind simultaneous re-parametrization
simul_reparam(te1, te2, mpath)
ElasticFDA.sqrt_mean
— MethodCalculate sqrt mean of warping functions
sqrt_mean(gam)
:param gam: array (M,N) describing warping functions
ElasticFDA.sqrt_mean_inverse
— MethodCalculate sqrt mean inverse of warping function
sqrt_mean_inverse(gam)
:param gam: array (M,N) describing warping functions
ElasticFDA.zero_crossing
— MethodCalculate zero crossing of optimal warping function
zero_crossing(Y,q,bt,timet,y_max,y_min,gmax,gmin)