infomeasure 0.1.0-alpha.1

Information theory measures and entropy calculations for Rust
Documentation
// Example demonstrating the new ANSB API with default and custom thresholds
use infomeasure::estimators::entropy::{Entropy, GlobalValue};
use ndarray::Array1;

fn main() {
    println!("=== ANSB API Example ===");

    // Sample data with coincidences for ANSB estimator
    let data = Array1::from(vec![1, 2, 3, 4, 5, 1, 2]);

    println!("Data: {data:?}");

    // Use default threshold (0.1)
    let est_default = Entropy::new_ansb(data.clone(), None);
    let h_default = est_default.global_value();
    println!("Default threshold (0.1): entropy = {h_default:.6}");

    // Use custom threshold (0.05 - more strict)
    let est_strict = Entropy::new_ansb_with_threshold(data.clone(), None, 0.05);
    let h_strict = est_strict.global_value();
    println!("Custom threshold (0.05): entropy = {h_strict:.6}");

    // Use custom threshold (0.5 - more lenient)
    let lenient = Entropy::new_ansb_with_threshold(data.clone(), None, 0.5);
    let h_lenient = lenient.global_value();
    println!("Custom threshold (0.5): entropy = {h_lenient:.6}");

    // Demonstrate batch API - create simple 2-row example
    let data_2d = ndarray::arr2(&[[1, 2, 3], [4, 5, 1]]);
    let batch_default = Entropy::new_ansb_rows(data_2d.clone(), None);
    let batch_custom = Entropy::new_ansb_rows_with_threshold(data_2d, None, 0.2);

    println!("\nBatch processing:");
    println!(
        "Row 1 [1,2,3] (default): {:.6}",
        batch_default[0].global_value()
    );
    println!(
        "Row 1 [1,2,3] (custom 0.2): {:.6}",
        batch_custom[0].global_value()
    );
    println!(
        "Row 2 [4,5,1] (default): {:.6}",
        batch_default[1].global_value()
    );
    println!(
        "Row 2 [4,5,1] (custom 0.2): {:.6}",
        batch_custom[1].global_value()
    );

    println!("\nNote: Warnings may appear for insufficiently undersampled data.");
    println!("ANSB requires N/K -> 0 for theoretical validity.");
}