Code covered by the BSD License  

Highlights from
Shannon-fano encoder

4.0
4.0 | 1 rating Rate this file 20 Downloads (last 30 days) File Size: 97.6 KB File ID: #41727 Version: 1.0

Shannon-fano encoder

by

 

13 May 2013 (Updated )

a shannonfano encoder with a row matrix input of occurrences/probab and outputs codewords&avelength

| Watch this File

File Information
Description

%made by Jamil Kasan from Manila, Philippines
%input = row matrix of occurrences or probabilities e.g. ss=[1 3 4 5] or
%ss=[0.4 0.3 0.2 0.1]
%outputs = string of codewords,average codeword length

to try its credibility, play sf encoder (need to change the location of ff7.txt)

sfencoderkasan is a function file for shannon-fano encoder
its input is a row matrix of occurrences or probabilities
its outputs are ​codex which is the codewords and T which is the average codeword length

Required Products MATLAB
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
14 Feb 2015 Jamil Kasan

@Robert Green, I reread my notes back from College, and I think the one in Wikipedia is wrong, it is actually fano coding, and what I made here is the real shannon-fano coding, but if you do want to have the fano code in c++, Id let you have it, thank you too that you made me get my notes back

Comment only
14 Feb 2015 Jamil Kasan

@Robert Green, sorry for that, I think I mislabelled it or I was just wrong, it was years ago that I do not remember it anymore, anyways, I made shannon fano encoder in c++ but it isn't refactored yet cause I just made it for 2 hours, I forgot to obey Uncle Bob this time
(If you wanted the code I just made, feel free to email me, in my informal email=kasan.jamil@yahoo.com)

Comment only
13 Feb 2015 Robert Green

your code is actually Shannon coding, not Shannon-Fano coding. see http://en.wikipedia.org/wiki/Shannon_coding

Comment only
13 Feb 2015 Robert Green

Hi Jamil. Thank you for the code, but this code doesn't seem to be correct. when yo give it the occurences [15,7,6,6,5] it returns codewords [00,011,100,101,110] which is not correct. The correct Shanon-Fano codewords are [00,01,10,110,111]. see http://en.wikipedia.org/wiki/Shannon%E2%80%93Fano_coding

Comment only
09 Nov 2013 Jamil Kasan

@ahmed
btw, thanks for the comment and rate

Comment only
09 Nov 2013 Jamil Kasan

@ahmed
the outputs are in string characters, only for display purposes, that's why.

Comment only
19 Oct 2013 ahmed

ahmed (view profile)

this is really amazing but when i tried it it gave me {1x1 cell} instead of all codes i tried to fix it but with no result can u just tell me why it gave my these results ?

15 May 2013 Jamil Kasan

the sfencoderkasan is a pcode, comment and rate please. pm me for the source code (mil1_hoopplayer@yahoo.com)

Comment only
13 May 2013 Jamil Kasan

Please comment or rate, that would be much appreciated. Thanks.

Comment only

Contact us