compute_frechet_mean {riemtan} | R Documentation |
Compute the Frechet Mean
Description
This function computes the Frechet mean of a sample using an iterative algorithm.
Usage
compute_frechet_mean(sample, tol = 0.05, max_iter = 20, lr = 0.2)
Arguments
sample |
An object of class |
tol |
A numeric value specifying the tolerance for convergence. Default is 0.05. |
max_iter |
An integer specifying the maximum number of iterations. Default is 20. |
lr |
A numeric value specifying the learning rate. Default is 0.2. |
Details
The function iteratively updates the reference point of the sample until the change in the reference point is less than the specified tolerance or the maximum number of iterations is reached. If the tangent images are not already computed, they will be computed before starting the iterations.
Value
The computed Frechet mean.
Examples
if (requireNamespace("Matrix", quietly = TRUE)) {
library(Matrix)
# Load the AIRM metric object
data(airm)
# Create a CSample object with example data
conns <- list(
diag(2) |> Matrix::nearPD() |> _$mat |> Matrix::pack(),
diag(c(2, 3)) |> Matrix::nearPD() |> _$mat |> Matrix::pack()
)
sample <- CSample$new(conns = conns, metric_obj = airm)
# Compute the Frechet mean
compute_frechet_mean(sample, tol = 0.01, max_iter = 50, lr = 0.1)
}
[Package riemtan version 0.1.0 Index]