如何随机选择n独特的preambles通过设备的K个一次没有repitition独特、设备、preambles、repitition

2023-09-11 07:10:46 作者:Bury(埋葬)

我有一些问题需要在MALAB实现。我有N个(的preambles号),以用K来选择(装置的数量)。如何随机选择N的装置的K个,因此能够1 preambles选择由一个以上的设备? 例如,有10个独特的preambles(N = 10),以随机由50台设备(K = 50),只是在一个时间,没有重复的选择和每K个设备只能选择一个来自10个独特的preamble通过随机的。我想知道,从那些10个独特的preambles,有多少被正好一个设备只和其中preambles被选择?多少preambles由一个以上的装置选择并preambles? 如何实现这个场景在MATLAB?我真的需要尽快你的回应。谢谢。

I have some problems to be implemented in malab. I have N (number of preambles) to be chosen by K (number of devices). How to randomly choose N by K number of devices, so it is possible one preambles chosen by more than one devices? for example there are 10 unique preambles (N=10) to be randomly chosen by 50 devices (K=50), just in one time with no repetition and each K devices only can choose one from 10 unique preamble by random. I would like to know from those 10 unique preambles, how many are chosen by exactly one devices only and which preambles? and how many preambles are chosen by more than one devices and which preambles? How to implement this scenario in matlab? I really need your response ASAP. thanks.

推荐答案

试试这个:

r = randperm(N*K); % generate a random permutation of the integers from 1 through N*K
r = mod(r(1:N:(K-1)*N+1), N); % the random selection results
[uniques,numUnique] = count_unique(r); % the selected preambles (uniques), and how many times they were selected (numUnique)

count_unique 函数可以找到这里

 
精彩推荐