arenc.m
来自「huffman 和 arithtic code run in the matla」· M 代码 · 共 32 行
M
32 行
function arcode=arenc(symbol,pr,seqin)% Usage: arcode=arenc(symbol,pr,seqin)% arithmetic encoding in decimal given a % symbol probability table.% output: % arcode: a decimal number, the lower bound of the final interval.% input:% symbol: the list of symbols, a row vector of single letters% pr: the corresponding probabilty of each symbol% seqin: the input sequence of symbols to be encoded.% (C) 2002 by Yu Hen Hu% created: 11/14/2002%high_range=[];for k=1:length(pr), high_range=[high_range sum(pr(1:k))];endlow_range=[0 high_range(1:length(pr)-1)];sbidx=zeros(size(seqin));for i=1:length(seqin), sbidx(i)=find(symbol==seqin(i));endlow=0; high=1;for i=1:length(seqin), range=high-low; high = low + range*high_range(sbidx(i)); low = low + range*low_range(sbidx(i));endarcode=low;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?