简体   繁体   English

如何逆转R中的反双曲正弦变换?

[英]How to reverse inverse hyperbolic sine transformation in R?

Transformation using inverse hyperbolic sine transformation could be done in R using this simple function: 使用反双曲正弦变换的变换可以使用这个简单的函数在R中完成:

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? 所以我的问题是:如何反转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. @ Maju116给出了正确答案,但他没有展示他的作品。 :-) :-)

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. 下面是如何推导反双曲正弦函数的逆与完整的R解一起生成函数和图。

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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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