pub struct Entropy {
pub byte_count: [u64; 256],
pub length: u64,
}
Expand description
Contains metadata about the file that’s being used in the Entropy calculation.
byte_count
is a lookup table that contains the number of occurances of
a byte specified by the index, e.g. 0x00 is byte_count[0]
.
length
is the number of bytes in the file.
Fields§
§byte_count: [u64; 256]
§length: u64
Implementations§
Source§impl Entropy
impl Entropy
Sourcepub fn new(file: &File) -> Entropy
pub fn new(file: &File) -> Entropy
Gets metadata for the Entropy calculation from a File reference
Sourcepub fn shannon_entropy(&self) -> f32
pub fn shannon_entropy(&self) -> f32
Measures the Shannon entropy based on the frequency table and returns it as a float.
The equation is defined as: H(X) = - \sum_{i=0}^{n} P(x_i) log_2 P(x_i) It can be described as the minimum number of bits (per symbol) to encode the input. Thus the output will be between 0 and 8. See https://en.wikipedia.org/wiki/Entropy_(information_theory) for more information.
Sourcepub fn metric_entropy(&self) -> f32
pub fn metric_entropy(&self) -> f32
Measures the metric entropy based on the Shannon entropy of the generated frequency table and returns it as a float between 0 and 1.
Metric entropy is derived by dividing the Shannon entropy by the length of the string being measured. It can be described as the uncertainty or randomness of a string, where 1 means information is uniformly distributed across the string.