简体   繁体   中英

How to reverse inverse hyperbolic sine transformation in R?

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM