use infomeasure::estimators::entropy::{Entropy, GlobalValue};
use ndarray::Array1;
fn main() {
println!("=== ANSB API Example ===");
let data = Array1::from(vec![1, 2, 3, 4, 5, 1, 2]);
println!("Data: {data:?}");
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}");
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}");
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}");
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.");
}