Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-10059

feature/bug in TRandom3

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Medium
    • Resolution: Won't Fix
    • Affects Version/s: 6.12/06
    • Fix Version/s: 6.18/00
    • Component/s: Math Libraries
    • Labels:
    • Environment:

      root

      Description

      Hello,

      it seems that there is small feature/bug in TRandom3.

      To illustrate it, please this line commands illustration:

      1) example of TRandom (which works), but which is not recommended since TRandom3 is supposed to be better (more uniform, bigger period, etc.)

      As you see below, each time we require a new random number, the seed is changed :
      this is a normal behaviour, and it allows, to store the seed for some analysis, for debugging purpose (for example if we wish to directly regenerate the random number for a given event without to have to generate the previous ones : for that we need to have access to the chosen seed of the current iteration)

       TRandom rand1
       rand1.GetSeed()
       (unsigned int) 65539
       
       rand1.Poisson(10)
       (int) 9
       rand1.GetSeed()
       (unsigned int) 1287164657
       
       rand1.Poisson(10)
       (int) 9
       rand1.GetSeed()
       (unsigned int) 116496463 (different to previous one)
       
       rand1.Poisson(10)
       (int) 8
       rand1.GetSeed()
       (unsigned int) 263326324 (different to previous one)
        

      The algorithm reason is that in the code of TRandom1::Rndm() (which is called by Poisson), the seed is updated :
      https://root.cern.ch/doc/master/TRandom_8cxx_source.html#l00541
      line 555 : update of the seed

      2) For TRandom3, the seed is not updated, so it is very painful if we wish to regenerate a number for a given seed : we don't know what was the seed.
      example :

       TRandom3 rand3
       
       rand3.GetSeed()
       (unsigned int) 4357
       rand3.Poisson(10)
       (int) 15
       rand3.GetSeed()
       (unsigned int) 3921153342
       
       rand3.Poisson(10)
       (int) 6
       rand3.GetSeed()
       (unsigned int) 3921153342
        

      etc... (I tried) : always the same seed

      We can see the reason in TRandom3::Rndm() : the seed is not updated :
      https://root.cern.ch/doc/master/TRandom3_8cxx_source.html#l00100

      -->Could it be fixed ?

      thank you

        Attachments

          Activity

            People

            • Assignee:
              dpiparo Danilo Piparo
              Reporter:
              escalier Marc Escalier
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Actual Start:
                Actual End: