[−][src]Struct entropy::Entropy
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
Methods
impl Entropy
[src]
pub fn new(file: &File) -> Entropy
[src]
Gets metadata for the Entropy calculation from a File reference
pub fn shannon_entropy(&self) -> f32
[src]
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.
pub fn metric_entropy(&self) -> f32
[src]
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.
Auto Trait Implementations
impl RefUnwindSafe for Entropy
impl Send for Entropy
impl Sync for Entropy
impl Unpin for Entropy
impl UnwindSafe for Entropy
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,