Dear R-users, I have a basic question about how to determine the antilog of a variable. Say I have some number, x, which is a factor of 2 such that x = 2^y. I want to figure out what y is, i.e. I am looking for the antilog base 2 of x. I have found log2 in the Reference Manual. But I am struggling how to get the antilog of that. Any help will be appreciated! > version platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 9.1 year 2004 month 06 day 21 language R ...heather
Searching for antilog function
6 messages · Heather J. Branton, Spencer Graves, Duncan Murdoch +1 more
Consider:
> exp(log(1:11))
[1] 1 2 3 4 5 6 7 8 9 10 11
> 2^log(1:11, 2)
[1] 1 2 3 4 5 6 7 8 9 10 11
> 2^logb(1:11, 2)
[1] 1 2 3 4 5 6 7 8 9 10 11
> 10^log10(1:11)
[1] 1 2 3 4 5 6 7 8 9 10 11
> 2^log2(1:11)
[1] 1 2 3 4 5 6 7 8 9 10 11
Does this answer the question?
hope this helps. spencer graves
Heather J. Branton wrote:
Dear R-users, I have a basic question about how to determine the antilog of a variable. Say I have some number, x, which is a factor of 2 such that x = 2^y. I want to figure out what y is, i.e. I am looking for the antilog base 2 of x. I have found log2 in the Reference Manual. But I am struggling how to get the antilog of that. Any help will be appreciated!
version
platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 9.1 year 2004 month 06 day 21 language R ...heather
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Spencer Graves, PhD, Senior Development Engineer O: (408)938-4420; mobile: (408)655-4567
On Wed, 24 Nov 2004 12:26:46 -0500, "Heather J. Branton" <hjb at pdq.com> wrote :
Dear R-users, I have a basic question about how to determine the antilog of a variable. Say I have some number, x, which is a factor of 2 such that x = 2^y. I want to figure out what y is, i.e. I am looking for the antilog base 2 of x. I have found log2 in the Reference Manual. But I am struggling how to get the antilog of that.
You seem to be confusing log with antilog, but log2(x) and 2^y are inverses of each other, i.e. log2(2^y) equals y and 2^log2(x) equals x (up to rounding error, of course). Duncan Murdoch
Thank you so much for each of your responses. But to make sure I am clear (in my own mind), is this correct? If x = 2^y Then y = log2(x) Thanks again. I know this is basic. ...heather
Duncan Murdoch wrote:
On Wed, 24 Nov 2004 12:26:46 -0500, "Heather J. Branton" <hjb at pdq.com> wrote :
Dear R-users, I have a basic question about how to determine the antilog of a variable. Say I have some number, x, which is a factor of 2 such that x = 2^y. I want to figure out what y is, i.e. I am looking for the antilog base 2 of x. I have found log2 in the Reference Manual. But I am struggling how to get the antilog of that.
You seem to be confusing log with antilog, but log2(x) and 2^y are inverses of each other, i.e. log2(2^y) equals y and 2^log2(x) equals x (up to rounding error, of course). Duncan Murdoch
_______________________________________________________________________
Heather J. Branton Public Data Queries
Data Specialist 310 Depot Street, Ste C
734.213.4964 x312 Ann Arbor, MI 48104
U.S. Census Microdata At Your Fingertips
http://www.pdq.com
On Wed, 24 Nov 2004 14:38:19 -0500, "Heather J. Branton" <hjb at pdq.com> wrote :
Thank you so much for each of your responses. But to make sure I am clear (in my own mind), is this correct? If x = 2^y Then y = log2(x)
Yes, that's right. Duncan Murdoch
Heather J. Branton <hjb <at> pdq.com> writes: : : Thank you so much for each of your responses. But to make sure I am : clear (in my own mind), is this correct? : : If x = 2^y : Then y = log2(x) : : Thanks again. I know this is basic. Although its not a proof, you can still use R to help you verify such hypotheses. Just use actual vectors of numbers and check that your hypothesis, in this case y equals log2(x), holds. For example, R> # try it out with the vector 1,2,3,...,10 R> y <- 1:10 R> y [1] 1 2 3 4 5 6 7 8 9 10 R> # now calculate x R> x <- log2(y) R> # lets see what 2^x looks like: R> 2^x [1] 1 2 3 4 5 6 7 8 9 10 R> # it gave back y!