简体   繁体   English

在分布式环境中生成均匀分布的随机数

[英]Generating uniformly distributed random numbers in distributed environment

I have to generate a "unique Random Number" in a Wireless sensor network which works on the principle of Gossiping. 我必须在按照闲聊原理工作的无线传感器网络中生成一个“唯一随机数”。

The requirements are: 要求是:

  1. Each node has to generate a unique Random Number , without having any shared knowledge of what other nodes have generated. 每个节点必须生成一个唯一的随机数而无需任何其他节点已共享的知识。
  2. The Distribution of the generated Random number should be uniform with respect to each other . 生成的随机数分布应该彼此相对均匀
  3. It would be preferable if the range of the generated random number is around 10-16 bits or may be lesser. 如果所生成的随机数的范围在10-16位左右或更小则将是优选的。

The limitations are: 限制是:

  1. One node has no idea what number the other nodes in the network are generating. 一个节点不知道网络中其他节点正在生成多少个。
  2. Implementation in C, C++. 用C,C ++实现。

I also have the provision of using a unique seed for random number generation. 我还提供了使用唯一种子进行随机数生成的规定。 the seed could be any number in the range 0-2^15 . 种子可以是0-2 ^ 15范围内的任何数字。

If there is no way of generating such numbers, then it would be helpful if there is any method by which I can meet some of the above requirements. 如果没有办法生成这样的数字,那么如果有任何一种方法可以满足上述一些要求,那将是有帮助的。

If you can suggest me some way to achieve this result it would be really helpful. 如果您可以建议我一些实现此结果的方法,那将非常有帮助。

for this solution to work you must know the total number of nodes in the generation network. 为了使该解决方案有效,您必须知道世代网络中的节点总数。 let this number be n . 将此数字设为n

the basic idea is to generate uniformly distributed random numbers on each participating node inside a given interval. 基本思想是在给定间隔内在每个参与节点上生成均匀分布的随机数。 the n intervals of the participating nodes must not overlap. 参与节点的n间隔不得重叠。 a shared seed does not complicate matters if the total number of nodes does not change and each node can be assigned statically some integer i <= n such that each number is issued exactly once. 如果节点总数不变,并且每个节点可以静态分配一些整数i <= n ,使得每个节点仅发出一次,则共享种子不会使问题变得复杂。 instead of generating a single random number on each turn, n numbers are generated, and node i takes the i -th number from this series. 不是在每个回合上生成一个随机数,而是生成n个数,并且节点i从该序列中获取第i个数。

however, the overall distribution of random numbers generated will not be uniform unless ...: 但是,除非...,否则生成的随机数的总体分布将不一致。

  • you synchronize random number generation. 您同步随机数生成。
  • all intervals have the same size. 所有间隔都具有相同的大小。

for information on random number generation on individual nodes see here . 有关在各个节点上生成随机数的信息, 请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM