how can i compute probabalies in haffmaneco
1 回表示 (過去 30 日間)
古いコメントを表示
how i can i compute probabalties to compress all letters small capital and numbers
3 件のコメント
採用された回答
Walter Roberson
2020 年 2 月 8 日
[unique_symbols, ~, bin_number] = unique(YourText(:));
symbol_counts = accumarray(bin_number, 1);
symbol_probs = symbol_counts ./ numel(YourText);
Alternately,
sparse_count = sparse(1, double(YourText(:)), 1);
[~, unique_symbols, symbol_counts] = find(sparse_count);
unique_symbols = char(unique_symbols.');
symbol_probs = symbol_counts.' ./ numel(YourText);
In both cases, after the code, unique_symbols will be a column vector of characters that exist in the text, and symbol_probs will be the corresponding probability.
The sparse() version has a minor flaw that it will fail if any characters in the text are binary 0.
その他の回答 (3 件)
Yusuf lamah
2020 年 2 月 8 日
2 件のコメント
Walter Roberson
2020 年 2 月 10 日
Are you certain that this remark about needing to know how to compute the probabilities is the answer that you needed to your question? You Accepted it ?
Yusuf lamah
2020 年 2 月 10 日
1 件のコメント
Walter Roberson
2020 年 2 月 10 日
That is not a continuation of this question.
You should first use Google Scholar to research the topic.
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!