Create a random bijective function which has same domain and range

狂风中的少年 提交于 2019-12-11 08:03:49

问题


Create a random bijective function which has same domain and range. By random bijective function I mean a function which maps the elements from domain to range using a random algorithm (or at least a pseudo-random algo), and not something like x=y. The domain and range can be a very small set sometimes like {1,2,3,4,5}, so a pairing function won't work. Also, computational resources are limited, so it should be a computationaly feasible function.

Edit: What I meant in the question was, say you have a list of 5 numbers A = {1,2,3,4,5}. Now what you want to do is create a random function f which when applied to the above set gives a set containing the same above numbers, but in a different order with a sufficiently high probability. Like if I did f(A) = B, then B could be {2,4,1,5,3}. So A to B maping is 1->2, 2->4, 4->1, 4->5 and 5 ->3. But if I did f(A) again then the mapping this time should be another such randomised one i.e. if f(A) = C, then C could be any one of the possible permutations of A with uniformly equal probability. This can easily be achieved by calculating the nth permutation. But what my doubt is that if I want to find out the mapping of a number from the set A in a given specific time interval, then can it be done in constant time and space.


回答1:


Well, classical Linear Congruential Generator has this property if it satisfies Hull-Dobell Theorem.

For example, Knuth LCG (a=6364136223846793005, c=1442695040888963407) will map 1:1 domain [0...264) to co-domain [0...264)



来源:https://stackoverflow.com/questions/48205823/create-a-random-bijective-function-which-has-same-domain-and-range

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!