0

An example for 0, 1, 2, 3, 4, 5 would be:

f(0)=5;
f(1)=1;
f(2)=0;
f(3)=4;
f(4)=2;
f(5)=3;

I have found f(x) = 911 * x % N to work where 911 can be any large prime number, but I noticed patterns in the list of numbers resulted. In a line chart with the resulted values, they look like fish fins. Not identical of course, the results are unique. It would be splendid if the results would appear more randomly distributed. I don't mind if you fix this function or produce a new one.

I aim to use this to generate random positions for users at website but DO NOT have the ability to pre-generate the shuffled/permuted input. I can only send x values to the server and return f(x). N and the function itself are serverside.

Thank you in advance.

Discipol
  • 131
  • In R: sample(1:n). – Raskolnikov May 07 '13 at 12:57
  • First, the range of the function is not a permutation of the domain; the range is the domain. What you mean to say is that the function should be a permutation. But not just any permutation; you want it to "appear more randomly distributed". Also, I have no idea what you mean when you say a list of numbers looks like fish fins. Anyway, I think the search term that can help you is "random permutation". Or maybe "pseudorandom permutation". – Gerry Myerson May 07 '13 at 12:59
  • I meant to say the chart where I added the results :D fixed it, sorry. Isn't there a classic formula for this, which mathematicians know by heart? Or is this harder than I think it is? – Discipol May 07 '13 at 13:03

0 Answers0