KIM-Convergence

0.0.3 · active · verified Fri Apr 17

kim-convergence is a Python library designed to assist in the automatic detection of equilibration and control of run lengths in simulations or data streams. It provides tools to determine when a time series of data has reached a steady state or converged. The current version is 0.0.3, with releases happening infrequently as major improvements or compatibility updates are needed.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `ConvergenceDetector` to identify the point at which a time series of data converges. It initializes a detector with 'rmse' criteria, a window size, and a threshold, then applies it to a sample 2D NumPy array.

import numpy as np
from kim_convergence import ConvergenceDetector

# Generate some example converging data (e.g., from a simulation)
np.random.seed(42)
time_series_data = np.concatenate([
    np.random.rand(50, 2) + np.array([10.0, 20.0]), # Initial transient
    np.random.rand(50, 2) * 0.1 + np.array([10.5, 20.5]) # Converged state
])

# Initialize the detector with desired criteria
# 'rmse' (Root Mean Square Error) is a common choice
detector = ConvergenceDetector(
    criteria='rmse',
    window_size=10, # Number of data points in the comparison windows
    threshold=0.1   # Maximum allowed difference for convergence
)

# Detect convergence
convergence_step = detector.detect_convergence(time_series_data)

if convergence_step is not None:
    print(f"Convergence detected at step: {convergence_step}")
    print(f"Data considered converged from index: {convergence_step}")
else:
    print("Convergence not detected within the given time series.")

view raw JSON →