LT code encoding with k packet using probability of Ideal Soliton matlab
2 views (last 30 days)
Show older comments
given data input K-packets and N packets I need to produce N packet codes, where each code is an ex-or combination of the original packet, I define d which is will be a random number that will tell me how many packets I can combine; each package will be generated automatically. Then create a probability of distribution of numbers between 1 and k probability which must be equal to 1: Soliton Distribution and calculate the probability of each value between 2 and k,all by using matlab function
0 Comments
Answers (1)
Gojo
on 29 Jan 2024
Hi Wael,
I understand that you have ‘K’ packets using which you wish to create ‘N’ packet codes. The packet code is generated by combining ‘d’ packets using an ex-or combination where ‘d’ is a random number generated using Ideal Soliton Distribution.
The Ideal Soliton distribution is given by:
P(1) =1/K ,
P(i) =1 / ( i * (i-1) ) (for i=2,3,4……K.)
You can refer to the following MATLAB Answer for generating the Ideal Soliton Distribution: https://www.mathworks.com/matlabcentral/answers/644135-ideal-soliton-distribution-code
After generating the probability distribution, you can generate a random number ‘d’ using the “randsample” function. The Soliton distribution can be passed as an argument in “randsample” function. You can refer to the documentation of “randsample” function: https://www.mathworks.com/help/stats/randsample.html
Please refer to the following code snippet:
K = 10;
N = 5;
% Randomly generating K-packets (input data)
K_packets = randi([0, 1], K, 8)
packet_codes = generate_packet_codes(K,K_packets, N)
function packet_codes = generate_packet_codes(K,K_packets, N)
% Calculate Soliton distribution probabilities
soliton_probs = zeros(1, K);
soliton_probs(1) = 1 / K;
for d = 2:K
soliton_probs(d) = 1 / (d * (d - 1));
end
% Ensure the probability distribution sums to 1
soliton_probs = soliton_probs / sum(soliton_probs);
% Generating N packet codes
packet_codes = zeros(N, 8);
for i = 1:N
% Generate 'd' using Soliton distribution
d = randsample(1:K, 1, true, soliton_probs);
% Randomly select d packets to XOR
packets_to_xor = randsample(1:K, d);
for j = 1:d
packet_codes(i, :) = bitxor(packet_codes(i, :), K_packets(packets_to_xor(j), :));
end
end
end
I have generated ‘K’ packets and a vector containing Soliton distribution for ‘K’ integers. I have used “randsample” to generate a random number ‘d’, and then selected ‘d’ random packets and combined them using XOR to generate ‘N’ packet codes.
I hope this helps.
0 Comments
See Also
Categories
Find more on Random Number Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!