Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • int(runiform(1,499999)) stata 13

    Hello to all, do you have a idea of wich command to use to have the same result...

    In stata 15 gen id= int(runiform(1,499999)) give me some result

    In stata 13
    Code:
    . gen id= int(runiform(1,499999))
    invalid syntax
    r(198);
    Thanks

  • #2
    I also try in stata 13
    Code:
    gen id = floor((499999)*runiform() + 1)
    gen id = 1+int((499999-1+1)*runiform())
    But did'nt give me the same result as stata 15 with
    Code:
    gen id= int(runiform(1,499999))
    Thanks

    Comment


    • #3
      With regard to #2, Stata switched to a different random number generator, Mersenne Twister, starting with version 14. Versions 13 and earlier used KISS32. So you will not get the same results. If it is important for you to be able to reproduce results in code that you must run under both versions, use version control, or -set rng kiss32- when running under version 15.

      I don't recall when the runiform() function was modified to allow you to specify lower and upper limits. I'm guessing from your experience in #1 that it was later than version 13.

      Comment

      Working...
      X