Announcement

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

  • Creating normally distriuted random variable given mean and standard deviation

    Hi all
    I would like to create a random variable (X) with 100 observations. The variable should follow the normal distribution with mean 15 and standard deviation 5. Can anybody suggest a code for this? Thanks.

  • #2
    Karim:
    you may want to try something along the following lines:
    Code:
    . drawnorm X, n(100) means(15) sds(5)
    
    
    . kdensity X
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thanks a lot.

      Comment


      • #4
        Dear Carlo
        Is it possible to have the variable X in a certain range say between 0 and 50, where 0 is the minimum and 50 is the maximum observation for X?

        Comment


        • #5
          Karim:
          not to my knowledge.
          In order to feed -drawnorm- you should recalculate mean and sd according to the range you're interested in.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            How does the request in #4 for prespecified bounds square with the request in #1 for a normal distribution? A normal distribution in principle has tails out to either infinity. Naturally you won't see that in samples.

            Comment

            Working...
            X