How to Calculate Antilog of Values in R
The antilogarithm (antilog) refers to the inverse operation of a logarithmic (log) number. The antilog is used for finding the original number from the log number.
For example, the antilog of the log with a base 10 (log10) value can be found by raising the base value (10) to the power of the log value. If log10(x) = z then the antilog of z is 10z.
The following examples illustrates for how to find antilog of various log bases,
Base | Log | Antilog |
---|---|---|
10 | log10(8) = 0.90309 | 100.90309 = 8 |
2 | log2(8) = 3 | 23 = 8 |
e | log(8) = 2.079442 | 2.71822.079442 = 8 |
In R, you can use the 10^x
, 2^x
, or exp(x)
functions to calculate the antilogs, depending on the base you
want to use.
Example 1: Calculate the antilog of the log10 value
Suppose you have a value of log10 as follows:
# calculate log10 value
log_val = log10(8)
# see log value
log_val
0.90309
Now, calculate the antilog of log10 value (0.90309) to get the original value of 8.
# raise base value 10 to the power of the log10 value
10^log_val
# output
8
By taking the antilog of log10 value, we obtained the original value of 8.
Example 1: Calculate the antilog of the log2 value
Suppose you have a value of log2 as follows:
# calculate log10 value
log_val = log2(8)
# see log value
log_val
3
Now, calculate the antilog of log2 value (3) to get the original value of 8.
# raise base value 2 to the power of the log2 value
2^log_val
# output
8
By taking the antilog of log2 value, we obtained the original values of 8.
Example 3: Calculate the antilog of natural log
Suppose you have a value of natural log as follows:
# calculate log10 value
log_val = log(8)
# see log value
log_val
2.079442
Now, calculate the antilog of natural log value (2.079442) to get the original value of 8.
You can use exp()
function to calculate the antilog of natural log value.
# calculate antilog
exp(log_val)
# output
8
By taking the antilog of natural log value, we obtained the original values of 8.
Related: How to Calculate Antilog of Values in Python
Enhance your skills with courses on Statistics and R
- Introduction to Statistics
- R Programming
- Data Science: Foundations using R Specialization
- Data Analysis with R Specialization
- Getting Started with Rstudio
- Applied Data Science with R Specialization
- Statistical Analysis with R for Public Health Specialization
This work is licensed under a Creative Commons Attribution 4.0 International License
Some of the links on this page may be affiliate links, which means we may get an affiliate commission on a valid purchase. The retailer will pay the commission at no additional cost to you.