小编Jam*_*mes的帖子

香农熵

以下 C++ 代码(按原样)来自http://rosettacode.org/wiki/Entropy。有错误 - 有人可以纠正吗?

#include <string>
#include <map>
#include <iostream>
#include <algorithm>
#include <cmath>

double log2( double number ) {
    return log( number ) / log( 2 ) ;
}

int main( int argc , char *argv[ ] ) {
    std::string teststring( argv[ 1 ] ) ;
    std::map<char , int> frequencies ;

    for ( char c : teststring )
        frequencies[ c ] ++ ;

    int numlen = teststring.length( ) ;
    double infocontent = 0 ;

    for ( …
Run Code Online (Sandbox Code Playgroud)

c++ entropy

0
推荐指数
1
解决办法
7979
查看次数

标签 统计

c++ ×1

entropy ×1