As programmer i find many solutions that generates pseudo-random values and surfaces, i'm always wondering how they can do that from a mathematical viewpoint.

For example i can generate a terrain from algorithms, i can input some parameters like the bottom and maximum height of the terrain and a seed to get the terrain that i want; i can't understand that from a mathematical viewpoint, if someone would explain this to me it would be great.

  • 1
    $\begingroup$ what is a seed? $\endgroup$ – Jorge Sep 12 '12 at 23:18
  • $\begingroup$ the number that you can use to rebuild and obtain the same placement in space, for example if say that the seed is 459593 and input this number you should be able to generate the same map as everybody else that are using this number. It's a "mathematical root" in some ways that parametrize everything. $\endgroup$ – Ken Sep 12 '12 at 23:23
  • $\begingroup$ what is a terrain? $\endgroup$ – Euler....IS_ALIVE Sep 12 '12 at 23:40

A pseudorandom number generator (PRNG) is a function that takes a seed and outputs a long sequence of seemingly random numbers. The algorithms you mention use a large quantity of random numbers to run. Using a PRNG, instead of specifying all of them, it is enough to specify a seed. In other words, a PRNG is a way of parametrizing a large number of random-looking sequences of numbers.

  • $\begingroup$ ok, so the "property" is that 1 function do the work for N values ? $\endgroup$ – Ken Sep 12 '12 at 23:45
  • $\begingroup$ Yes; you iterate that one function as many times as you need, to generate as many values as you need. Starting with the seed $x_0$, and a function $f$, you produce $x_1,x_2,\dots$ via the formula $x_{n+1}=f(x_n)$. $\endgroup$ – Gerry Myerson Sep 13 '12 at 6:57
  • $\begingroup$ @Gerry, this is not an accurate description of a PRNG: it has an internal state, and you only get to see part of it. And you have a seeding function. So what happens is that you have a seed function $i$, a transition function $m$, and an output function $o$, and the outputs, under seed $s$, are $(o \circ m^{(t)} \circ i)(s)$, for $t \in \mathbb{N}$. $\endgroup$ – Yuval Filmus Sep 14 '12 at 5:08
  • $\begingroup$ I was thinking of the kind of PRNG based on $x_{n+1}=ax_n+b$ reduced modulo $m$; you plug in an $x_0$, and it churns out $x_1,x_2,\dots$. Anyway, what's important is whether OP has an answer he/she can understand and use. $\endgroup$ – Gerry Myerson Sep 14 '12 at 6:30
  • $\begingroup$ For anyone who's reading this, don't use the PRNG $x_{n+1} = ax_n + b \pmod{m}$, your programs might produce the wrong results! $\endgroup$ – Yuval Filmus Sep 14 '12 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.