+1 vote
asked by (170 points)

Hi,

For a randomized MPS, psi, created by the following
auto psi = MPS(sites);
is there a way to fix the random seed?

I have tried Global::random(random_seed) suggested by http://itensor.org/support/348/fixing-random-generators. It doesn't work.

Thanks in advance.

1 Answer

+1 vote
answered by (70.1k points)
selected by
 
Best answer

Hi, good question. So what's going on is that there is another random number generator which is optimized for speed over quality for certain internal uses.

So to make it easier to set a random seed and not have to worry about which random number generator gets used where, I just pushed an update to ITensor that now includes a function "seedRNG(int)".

So you can just do: seedRNG(seed); and it will seed all of the random generators used throughout ITensor (just two of them at the moment).

If you want more details about the other one, I can tell you more about it, but it's only intended for certain cases where one wants sort of a "quick and dirty" random number generator (it's just a linear congruential generator).

Best regards,
Miles

commented by (170 points)
Thanks so much. I really appreciate your quick help.
I would definitely like to hear more about the other generator and why it is used in some cases and not in others.

Thanks,
Andy
commented by (70.1k points)
The other generator is called "quickran" and it can be called as:
detail::quickran()
which will return a real number (double) between 0 and 1.

It's there as an optimization, with the thinking that tensors can sometimes be very big and yet randomizing them can be a key part of certain algorithms (like orthogonalizing tensors can sometimes fail and then one randomizes them to recover).

But in hindsight it could be sort of a "premature optimization" in the sense that it could be speeding up parts of the code which were never a bottleneck to begin with. So it would be interested to replace it with the better quality random number generator, just as a test, and see if any major parts of the code slows down.
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.

Categories

...