PseudoRandom functions in C++
-
Hey all, I want to use pseudo random functions in C++, such that they take input parameters, and based on this input give output. i.e.
function(param1, param2).
My problem is that what I find on the internet are just simple random number generators based on seeds, which is not what I want. Does anyone know, if there is any class that I could use for above-stated purposes. ? Thanks -
Hey all, I want to use pseudo random functions in C++, such that they take input parameters, and based on this input give output. i.e.
function(param1, param2).
My problem is that what I find on the internet are just simple random number generators based on seeds, which is not what I want. Does anyone know, if there is any class that I could use for above-stated purposes. ? Thanks
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all.
Douglas Adams, "Dirk Gently's Holistic Detective Agency" -
Hey all, I want to use pseudo random functions in C++, such that they take input parameters, and based on this input give output. i.e.
function(param1, param2).
My problem is that what I find on the internet are just simple random number generators based on seeds, which is not what I want. Does anyone know, if there is any class that I could use for above-stated purposes. ? ThanksWhat exactly are you trying to do here? There isn't any reason to think that two or more seed parameters will be any better than a single well chosen seed. Since any random number generator basically produces a repeating (but repeating with a HUGE period) sequence that looks random, and since seeding the generator just tells the RNG where to begin iterating through that sequence, passing in multiple values won't get you anything better than passing in a single numerical value. Without knowing more about what your goal is, I would say to just use one parameter, or combine them into a single seed value, or something like that.
-
What exactly are you trying to do here? There isn't any reason to think that two or more seed parameters will be any better than a single well chosen seed. Since any random number generator basically produces a repeating (but repeating with a HUGE period) sequence that looks random, and since seeding the generator just tells the RNG where to begin iterating through that sequence, passing in multiple values won't get you anything better than passing in a single numerical value. Without knowing more about what your goal is, I would say to just use one parameter, or combine them into a single seed value, or something like that.
I see what you mean Nathan. Yes, I could combine the values into one as well. What I need it for example following. I have a pseudorandom function F. And say F(x) = y. So that everytime I call the function with parameter x, it outputs y.
-
Hey all, I want to use pseudo random functions in C++, such that they take input parameters, and based on this input give output. i.e.
function(param1, param2).
My problem is that what I find on the internet are just simple random number generators based on seeds, which is not what I want. Does anyone know, if there is any class that I could use for above-stated purposes. ? ThanksYour terminology is confusing, random is a property of a sequence not a function, so pseudo-random generators produce a pseudo-random stream of values, you can initialise this from a seed. It sounds that you are looking for a one-way or trapdoor function, where given x, the value f(x) appears random and difficult to invert to produce x. You could look at the standard hash functions (e.g. MD5), or alternatively something simple like exponentiation modulo some prime e.g. f(x) = r^x (mod p) where r is a primitive root mod p.
Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
-
I see what you mean Nathan. Yes, I could combine the values into one as well. What I need it for example following. I have a pseudorandom function F. And say F(x) = y. So that everytime I call the function with parameter x, it outputs y.
Then use a manually mathematic formulem as you want. You will always have the same output for the same input. I.E y = ABS( (((((3 - (x+1)) * (x-1) / 1.5) + ((2 - (x/5) + (x - 2/3))) / ((1 - x/7) + 2 * (x+1))) And if you want the result to be between 0 and 1, normalize the output or just divide y /= y+1;
Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson ;)