Transformation using inverse hyperbolic sine transformation could be done in R using this simple function:
ihs <- function(x) {
y <- log(x + sqrt(x ^ 2 + 1))
return(y)
}
However, I could not find the way to reverse this transformation. So my question is: How to reverse inverse hyperbolic sine transformation in R?
The inverse of inverse hyperbolic sine is hyperbolic sine so you can use:
sinh(x)
And if you want to inverse the function on your own that should help you:
hs <- function(x) {
y <- 0.5*exp(-x)*(exp(2*x)-1)
return(y)
}
@Maju116 has given the right answer, but he has not shown his work. :-)
Here is how to derive the inverse of the inverse hyperbolic sine function together with a full R solution to generate the function and plots.
y = \log(x + \sqrt{x^2 + 1})
\exp(y) - x = \sqrt{x^2 + 1}
Squaring both sides
\exp(2y) + x^2 - 2\exp(y)x = x^2 + 1
\exp(2y) - 1 = 2\exp(y)x
(1/2)*(\exp(2y) - 1)/exp(y) = x
Plot of the functions:
library(ggplot2)
# inverse hyperbolic since function
ihs <- function(x) {
y <- log(x + sqrt(x^2 + 1))
return(y)
}
# hyperbolic sine function
hs = function(x) {
0.5*exp(-x)*(exp(2*x) - 1)
}
# data
dfX = data_frame(x = seq(-2, 2, 0.01),
ihs = ihs(x),
hs1 = sinh(x),
hs2 = hs(x))
# plot
ggplot(data = dfX, aes(x = x)) +
stat_function(aes(color = "Inverse Hyperbolic Sine"), fun = ihs, ) +
stat_function(aes(color = "Hyperbolic Sine (Manual)"), fun = hs) +
stat_function(aes(color = "Hyperbolic Sine (Base)"), fun = sinh) +
theme_bw() +
scale_colour_manual("Function", values = c("red", "darkblue", "darkgreen"))][1]][1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With