MCPcopy Create free account
hub / github.com/Open-Quant/openquant / get_konto_entropy

Function get_konto_entropy

crates/openquant/src/microstructural_features.rs:588–611  ·  view source on GitHub ↗
(message: &str, window: usize)

Source from the content-addressed store, hash-verified

586}
587
588pub fn get_konto_entropy(message: &str, window: usize) -> f64 {
589 if message.len() < 2 {
590 return 0.0;
591 }
592 let points: Vec<usize> = if window == 0 {
593 (1..=message.len() / 2).collect()
594 } else {
595 let w = window.min(message.len() / 2);
596 (w..=message.len() - w).collect()
597 };
598 let mut sum = 0.0;
599 let mut num = 0.0;
600 for i in points {
601 let l = match_length(message, i, if window == 0 { i } else { window });
602 let denom = if window == 0 { (i + 1) as f64 } else { (window + 1) as f64 };
603 sum += denom.log2() / l as f64;
604 num += 1.0;
605 }
606 if num == 0.0 {
607 0.0
608 } else {
609 sum / num
610 }
611}
612
613pub struct MicrostructuralFeaturesGenerator {
614 tick_num_iter: std::vec::IntoIter<usize>,

Callers 3

ms_get_konto_entropyFunction · 0.85

Calls 2

match_lengthFunction · 0.85
lenMethod · 0.80

Tested by 1