BitVecEntropy

Table of Contents

BitVecEntropy

Description

Calculate information entropy of a bitvector. Entropy measures the randomness/information content of the bit pattern.

Parameters

NameDirectionDescription
bvinBitvector to analyze

Usage example (from documentation)

  double entropy = BitVecEntropy(&flags);

Usage example (Cross-references)

    }
    
    double BitVecEntropy(BitVec *bv) {
    ValidateBitVec(bv);
    // Test BitVecEntropy basic functionality
    bool test_bitvec_entropy_basic(void) {
    WriteFmt("Testing BitVecEntropy basic functionality\n");
    
    BitVec bv     = BitVecInit();
    BitVecPush(&bv, false);
    
    double entropy = BitVecEntropy(&bv);
    result         = result && (fabs(entropy - 1.0) < 0.001);
    BitVecPush(&bv, true);
    
    entropy = BitVecEntropy(&bv);
    result  = result && (entropy == 0.0);
    // Test BitVecEntropy edge cases
    bool test_bitvec_entropy_edge_cases(void) {
    WriteFmt("Testing BitVecEntropy edge cases\n");
    
    BitVec bv     = BitVecInit();
    
    // Test empty bitvector
    double entropy = BitVecEntropy(&bv);
    result         = result && (entropy == 0.0);
    // Test single bit
    BitVecPush(&bv, true);
    entropy = BitVecEntropy(&bv);
    result  = result && (entropy == 0.0);
    u64    dot_prod    = BitVecDotProduct(&bv1, &bv2);
    double correlation = BitVecCorrelation(&bv1, &bv2);
    double entropy1    = BitVecEntropy(&bv1);
    int    align_score = BitVecAlignmentScore(&bv1, &bv2, 1, -1);
    u64    best_align  = BitVecBestAlignment(&bv1, &bv2);
    
    bool test_bitvec_entropy_null(void) {
    WriteFmt("Testing BitVecEntropy(NULL) - should fatal\n");
    BitVecEntropy(NULL);
    return true;
    bool test_bitvec_entropy_null(void) {
    WriteFmt("Testing BitVecEntropy(NULL) - should fatal\n");
    BitVecEntropy(NULL);
    return true;
    }

Share :

Related Posts

BitVecEditDistance

BitVecEditDistance Description Calculate edit distance between two bitvectors. Edit distance is minimum number of single-bit operations to transform one into the other.

Read More

BitVecDotProduct

BitVecDotProduct Description Calculate dot product of two bitvectors. Dot product is the count of positions where both bits are 1.

Read More

BitVecJaccardSimilarity

BitVecJaccardSimilarity Description Calculate Jaccard similarity between two bitvectors. Jaccard similarity = |intersection| / |union|

Read More