2

I have read that "the computational complexity of the Mersenne twister is O(p2) where p is the degree of the polynomial".

  • What does this mean?
  • Which polynomial is this referring to?
  • Also, is computational complexity another way of saying time complexity, or does this have to do with the amount of space the algorithm takes to run?
IvyMike
  • 2,199
  • 4
  • 19
  • 31
hannah
  • 889
  • 4
  • 13
  • 27

2 Answers2

5

Generating 2 n random numbers takes twice as long as generating n random numbers, so the time complexity of Mersenne Twister is O(1), meaning that it takes a constant amount of time to generate a single random number; note that this is probably amortized complexity, as Mersenne Twister generally computes a batch of random numbers then doles them out one at a time until the batch is consumed, at which time it computes more. The Google search that you reference is saying the same thing, although it tries to more precisely determine the constant. Computational complexity generally refers to time complexity, though in some contexts it could also refer to space complexity.

user448810
  • 17,381
  • 4
  • 34
  • 59
2

If you look at the C source code for the generate function in their original paper, you'll see that MT generates N words at a time using two loops that total out to N-1 iterations, and that the computations within each loop are a fixed number of arithmetic or bitwise operations. After the loops a fixed number of additional arithmetic/bitwise operations are performed. Consequently, generate takes O(N) time to produce N words, for an amortized O(1) time per word generated.

pjs
  • 18,696
  • 4
  • 27
  • 56