compute_frechet_mean | R Documentation |
This function computes the Frechet mean of a sample using an iterative algorithm.
compute_frechet_mean(sample, tol = 0.05, max_iter = 20, lr = 0.2)
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. |
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.
The computed Frechet mean.
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.