Learn R Programming

topolow (version 1.0.0)

check_gaussian_convergence: Check Multivariate Gaussian Convergence

Description

Assesses convergence of multivariate samples by monitoring changes in mean vector and covariance matrix over a sliding window. Useful for checking stability of parameter distributions in optimization or sampling.

Usage

check_gaussian_convergence(data, window_size = 300, tolerance = 0.01)

Value

An object of class topolow_convergence containing diagnostics about the convergence of the multivariate samples. This list includes:

converged

A logical flag, TRUE if both mean and covariance have converged.

mean_converged

A logical flag, TRUE if the mean vector has converged.

cov_converged

A logical flag, TRUE if the covariance matrix has converged.

final_mean

The mean vector calculated from the last window_size samples.

final_cov

The covariance matrix calculated from the last window_size samples.

mean_history

A matrix tracking the history of the running mean of each parameter.

cov_changes

A numeric vector of the relative changes in the Frobenius norm of the covariance matrix.

param_names

The names of the parameters (columns) from the input data.

Arguments

data

Matrix or data frame of samples where columns are parameters

window_size

Integer size of sliding window for statistics

tolerance

Numeric convergence threshold for relative changes

Examples

Run this code
# Assuming 'chain_data' is a data frame with samples
chain_data <- as.data.frame(matrix(rnorm(500 * 4), ncol = 4))
colnames(chain_data) <- c("log_N", "log_k0", "log_cooling_rate", "log_c_repulsion")
conv_results <- check_gaussian_convergence(chain_data)
print(conv_results)  # Shows summary
# The plot method for this object would create convergence plots.
# plot(conv_results)

Run the code above in your browser using DataLab