Comprehensive Adaptive Estimators API

LRDBenchmark provides a comprehensive suite of 13 adaptive classical estimators that automatically select the optimal computation framework (GPU/JAX, CPU/Numba, or NumPy) based on data characteristics and hardware availability.

Optimization Backend

The intelligent optimization backend automatically selects the best computation framework for each estimator based on data size, hardware availability, and performance characteristics.

Comprehensive Adaptive Estimators

All comprehensive adaptive estimators inherit from the base class and provide automatic framework selection, robust error handling, and performance profiling.

Temporal Estimators

Comprehensive Adaptive R/S Analysis

Comprehensive Adaptive DFA

Comprehensive Adaptive DMA

Comprehensive Adaptive Higuchi

Spectral Estimators

Comprehensive Adaptive GPH

Comprehensive Adaptive Whittle

Comprehensive Adaptive Periodogram

Wavelet Estimators

Comprehensive Adaptive CWT

Comprehensive Adaptive Wavelet Variance

Comprehensive Adaptive Wavelet Log Variance

Comprehensive Adaptive Wavelet Whittle

Multifractal Estimators

Comprehensive Adaptive MFDFA

Comprehensive Adaptive Wavelet Leaders

Factory Functions

Get All Comprehensive Adaptive Estimators

Usage Examples

Basic Usage with Automatic Framework Selection

from lrdbenchmark.analysis.comprehensive_adaptive_estimators import get_all_comprehensive_adaptive_classical_estimators
from lrdbenchmark import FBMModel
import numpy as np

# Get all comprehensive adaptive estimators
estimators = get_all_comprehensive_adaptive_classical_estimators()

# Generate test data
model = FBMModel(H=0.7, sigma=1.0)
data = model.generate(1000, seed=42)

# Test a few key estimators
test_estimators = ['Comprehensive_RS', 'Comprehensive_DFA', 'Comprehensive_GPH', 'Comprehensive_CWT']

for name in test_estimators:
    estimator = estimators[name]
    result = estimator.estimate(data)
    print(f"{name}: Hurst={result['hurst_parameter']:.4f}, "
          f"Framework={result['framework_used']}, "
          f"Time={result['execution_time']:.4f}s")

Performance Monitoring

from lrdbenchmark.analysis.comprehensive_adaptive_estimators import ComprehensiveAdaptiveRS
from lrdbenchmark import FBMModel
import numpy as np

# Create estimator with performance profiling
estimator = ComprehensiveAdaptiveRS(enable_profiling=True)

# Generate test data
model = FBMModel(H=0.7, sigma=1.0)
data = model.generate(1000, seed=42)

# Run multiple estimations
for i in range(5):
    result = estimator.estimate(data)
    print(f"Run {i+1}: Framework={result['framework_used']}, "
          f"Time={result['execution_time']:.4f}s")

# Get performance information
perf_info = estimator.get_performance_info()
print(f"\nPerformance Summary:")
print(f"Total runs: {perf_info['total_runs']}")
print(f"Frameworks used: {perf_info['frameworks_used']}")

EEG Contamination Testing

from lrdbenchmark.analysis.comprehensive_adaptive_estimators import ComprehensiveAdaptiveDFA
from lrdbenchmark import ContaminationFactory, ConfoundingScenario
from lrdbenchmark import FBMModel
import numpy as np

# Create estimator and contamination factory
estimator = ComprehensiveAdaptiveDFA()
contamination_factory = ContaminationFactory()

# Generate pure data
model = FBMModel(H=0.7, sigma=1.0)
pure_data = model.generate(1000, seed=42)

# Test with EEG contamination scenarios
eeg_scenarios = [
    ConfoundingScenario.EEG_OCULAR_ARTIFACTS,
    ConfoundingScenario.EEG_MUSCLE_ARTIFACTS,
    ConfoundingScenario.EEG_CARDIAC_ARTIFACTS,
    ConfoundingScenario.EEG_60HZ_NOISE
]

print("EEG Contamination Testing:")
print(f"Pure data H estimate: {estimator.estimate(pure_data)['hurst_parameter']:.4f}")

for scenario in eeg_scenarios:
    contaminated_data, description = contamination_factory.apply_confounding(
        pure_data, scenario, intensity=0.3
    )
    result = estimator.estimate(contaminated_data)
    print(f"{scenario.value}: H={result['hurst_parameter']:.4f}")

Framework Selection Examples

from lrdbenchmark.analysis.comprehensive_adaptive_estimators import ComprehensiveAdaptiveGPH
from lrdbenchmark import FBMModel
import numpy as np

# Test with different data sizes to see framework selection
model = FBMModel(H=0.7, sigma=1.0)

data_sizes = [100, 500, 1000, 5000, 10000]

for size in data_sizes:
    data = model.generate(size, seed=42)
    estimator = ComprehensiveAdaptiveGPH()
    result = estimator.estimate(data)

    print(f"Data size: {size:5d}, "
          f"Framework: {result['framework_used']:15s}, "
          f"Time: {result['execution_time']:.4f}s, "
          f"H: {result['hurst_parameter']:.4f}")

Error Handling and Robustness

from lrdbenchmark.analysis.comprehensive_adaptive_estimators import ComprehensiveAdaptiveCWT
import numpy as np

estimator = ComprehensiveAdaptiveCWT()

# Test with various data conditions
test_cases = {
    'Short data': np.random.randn(50),
    'Medium data': np.random.randn(500),
    'Long data': np.random.randn(5000),
    'Noisy data': np.random.randn(1000) + 0.5 * np.random.randn(1000),
    'Trend data': np.cumsum(np.random.randn(1000)) + np.linspace(0, 10, 1000)
}

for name, data in test_cases.items():
    try:
        result = estimator.estimate(data)
        print(f"{name:15s}: H={result['hurst_parameter']:.4f}, "
              f"Framework={result['framework_used']}")
    except Exception as e:
        print(f"{name:15s}: Failed - {e}")

Best Practices

  1. Automatic Framework Selection: Let the system automatically choose the best framework

  2. Performance Profiling: Enable profiling for performance monitoring

  3. Error Handling: Always handle potential estimation errors gracefully

  4. Data Validation: Ensure data meets minimum requirements for reliable estimates

  5. Multiple Estimators: Compare results from different estimator types

  6. Contamination Testing: Test robustness with realistic contamination scenarios

Note

The comprehensive adaptive estimators automatically handle framework selection, error recovery, and performance optimization. They provide the most robust and efficient way to use classical LRD estimators.

Warning

While the adaptive system handles most edge cases automatically, very short data (< 50 points) may still produce unreliable results regardless of the framework used.