15 Jan 16:56
s
# Prawdopodobieństwa z zadania 1.A
probabilities_A = {
0: 0.3,
1: 0.2,
2: 0.16,
3: 0.12,
4: 0.1,
5: 0.06,
6: 0.04,
7: 0.02
}
# Wiadomość z zadania 1.C
probabilities_C = {
0: 0.9,
1: 0.02,
2: 0.02,
3: 0.02,
4: 0.01,
5: 0.01,
6: 0.01,
7: 0.01
}
SymbolList_C = list(probabilities_C.keys())
SymbolProbs_C = list(probabilities_C.values())
NumSymbols_C = 10000
long_random_sequence_C = np.random.choice(SymbolList_C, NumSymbols_C, p=SymbolProbs_C)
# Sprawdzenie działania funkcji HuffmanEncodeDecode
HuffmanEncodeDecode(probabilities_A, long_random_sequence_C)