function [symb, prob, decimal_stream] = get_symbols(bitstream, bits_per_word)

len = length(bitstream);

if mod(len, bits_per_word) ~= 0
    disp('The length of the bitstream has to be a multiple of the bits_per_word parameter.')
    return
end

num_symbols    = len / bits_per_word;
decimal_stream = zeros(1, num_symbols);

for dec_idx = 1 : num_symbols
    bin_idx = (dec_idx-1) * bits_per_word + 1;
    end_idx = bin_idx + bits_per_word - 1;
    
    decimal_stream(dec_idx) = bin2dec(bitstream(bin_idx:end_idx), false);
end

% Compute the frequency of each symbol
unique_symbs = unique(decimal_stream);
prob         = histc(decimal_stream, unique_symbs) / num_symbols;

symb = unique_symbs;

end