Announcement

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

  • Euler's Number in Stata

    Hello,
    I am trying to define a program with:

    program define MC_3, rclass
    version 15
    clear
    drop _all
    set obs 200

    gen x = runiform(0,5)
    gen U = rnormal(0,100)
    gen m = e^x - 4*(x^2)
    gen Y = m+U
    end

    e is supposed to be Euler's number but it shows up as 'e not found'. How can I distinguish between e as Euler's number and e as a return command?

    Thanks in advance,
    Rayne
    Last edited by Rayne Zhao; 28 Nov 2020, 12:02.

  • #2
    https://www.stata.com/support/faqs/s...roni-constant/

    Comment


    • #3
      In context, it appears to me that Rayne wants e, not the other Euler constant, in which case Rayne needs to use functional notation, i.e., exp(x, ) not e^x. Every computer language I know uses exp(x) for this purpose, so Stata is standard in this respect.

      Comment


      • #4
        Originally posted by Mike Lacy View Post
        In context, it appears to me that Rayne wants e, not the other Euler constant, in which case Rayne needs to use functional notation, i.e., exp(x, ) not e^x. Every computer language I know uses exp(x) for this purpose, so Stata is standard in this respect.
        Rayne Zhao Mike’s answer is spot on, please ignore the link I pasted.

        Comment


        • #5
          Thank you both!

          Comment

          Working...
          X