Announcement

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

  • random number generation

    using stata 13 I have set a seed value and using gen random=runiform() generated random numbers. When I used the same seed in stata 16 and used gen random=runiform() the resulting random numbers are different why so? when i opened the saved file (version 13) in stata 16 and tried gen random1=ran it gave same random numbers but gen random1=ran gave error in new window of stata 16.
    Please advise.

  • #2
    See #15 of

    Code:
    help whatsnew13to14

    15. New random-number generators (RNGs)
    The previous RNGs are still used under version control, so if you want to replicate the results of Version 13 in Version 16, prefix the command with the version.

    Code:
    version 13: gen random=runiform()

    Comment


    • #3
      There is a discussion of random number generation in the output of
      Code:
      help set rng
      from which we learn that, on Stata 16, if you do
      Code:
      set rng kiss32
      at the top of your do-file in Stata 16, before any other random number commands or function callss, you will not need to use version control on every command that generates random numbers.
      Code:
      if `c(stata_version)'>13 set rng kiss32
      should work in all versions of Stata.
      Code:
      .  display "`c(stata_version)'"
      17
      
      . display "`c(rng_current)'"
      mt64
      
      . if `c(stata_version)'>13 set rng kiss32
      
      . display "`c(rng_current)'"
      kiss32
      
      .

      Comment

      Working...
      X