如何随机选择n独特的preambles通过设备的K个一次没有repitition [英] How to randomly choose N unique preambles by K number of devices at once with no repitition

查看:169
本文介绍了如何随机选择n独特的preambles通过设备的K个一次没有repitition的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题需要在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 函数可以找到<一href="http://www.mathworks.com/matlabcentral/fileexchange/23333-determine-and-count-unique-values-of-an-array"相对=nofollow>这里

这篇关于如何随机选择n独特的preambles通过设备的K个一次没有repitition的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆