Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: re:locating the natural log of a number


From   "Victor M. Zammit" <[email protected]>
To   <[email protected]>
Subject   Re: st: re:locating the natural log of a number
Date   Sun, 1 Apr 2007 21:59:04 +0100

I was trying to pin down the exact power to which e must be raised to get
the number in question.The bottom line seems to be  boiling down to the
exact figure and it is a matter of a number of reiterations that does not
necessarily give me an exact figure.But this was just an experiment I was
having fun with .
The following containes some adjustments that I have added to the program
,which got me very close to the figure,but not quite.i am however satisfied
with that. :
drop _all

set obs 1000

gen a = .

gen exp = .

local n = 1

while `n'<= 1000 {

local e =.01

while `e'<= 10 {

replace exp = `e' in `n'

replace a = `n' in `n'

local e = `e'+.01

local n = `n'+1

}

}

gen nl = 20000

gen x = 2.718281828^exp

gen diff = x-nl

keep diff exp

save diff,replace

keep if diff<0

qui summ exp

local l = r(max)

di `l'

di 2.718281828^`l'

drop _all

use diff,clear

keep if diff>0

qui summ exp

local h = r(min)

di `h'

di 2.718281828^`h'

drop _all

set obs 2000

gen a = .

gen exp = .

local n = 1

while `n'<= 2000 {

local e = `l'

while `e'<= `h' {

capture replace exp = `e' in `n'

capture replace a = `n' in `n'

local e = `e'+.0001

local n = `n'+1

}

}

gen nl = 20000

gen x = 2.718281828^exp

gen diff = x-nl

keep diff exp

save diff,replace

keep if diff<0

qui summ exp

local l = r(max)

di `l'

di 2.718281828^`l'

drop _all

use diff,clear

keep if diff>0

qui summ exp

local h = r(min)

di `h'

di 2.718281828^`h'

drop _all

set obs 2000

gen a = .

gen exp = .

local n = 1

while `n'<= 2000 {

local e = `l'

while `e'<= `h' {

capture replace exp = `e' in `n'

capture replace a = `n' in `n'

local e = `e'+.000001

local n = `n'+1

}

}

gen nl = 20000

gen x = 2.718281828^exp

gen diff = x-nl

keep diff exp

save diff,replace

keep if diff<0

qui summ exp

local l = r(max)

di `l'

di 2.718281828^`l'

drop _all

use diff,clear

keep if diff>0

qui summ exp

local h = r(min)

di `h'

di 2.718281828^`h'

end




----- Original Message ----- 
From: "Richard Williams" <[email protected]>
To: <[email protected]>
Sent: Sunday, April 01, 2007 8:47 PM
Subject: Re: st: re:locating the natural log of a number


> At 07:15 AM 4/1/2007, Victor M. Zammit wrote:
> >I am just trying to understand what goes on in the process of finding the
> >natural log of a number by rewriting a small proram myself
> >Victor M.Zammit
>
> OK.  But in that case I am not sure what the problem is, since the
> code you posted works for me.  You may want to make sure your copy of
> Stata is up to date.  Or, if it is different code that is causing the
> problem, post it.
>
>
> -------------------------------------------
> Richard Williams, Notre Dame Dept of Sociology
> OFFICE: (574)631-6668, (574)631-6463
> HOME:   (574)289-5227
> EMAIL:  [email protected]
> WWW:    http://www.nd.edu/~rwilliam
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index