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
What's wrong with log2()?> log2(16)[1] 4 Isn't that exactly what you asked for? Andy> From: Heather J. Branton > > 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 > >
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
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!
Use power> log(78,10)[1] 1.892095> 10^log(78,10)[1] 78 On Tue, May 31, 2016 at 4:14 PM, Carlos <arnobras at hotmail.com> wrote:> The following function can do the work as well > > antilog<-function(lx,base) > { > lbx<-lx/log(exp(1),base=base) > result<-exp(lbx) > result > } > > This solution is based on the change of base formula which states that : > > log (x,base=b) = log(x,base=a)/log(b,base=a) > > The original logarithm is changed into natural logarithm and then the > exponential function is employed > > The arguments are: > > 'lx', de logarithm we have. > 'base', the base what was employed to obtain lx > > For example: > > log(78,10) = 1.892095 > > Then the antllog is > > antilog(1.892095,10) > > 78 > > As expected. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.