我有一个PDF,它是价格的函数。说f(p)
。我希望有相同的PDF函数用于退货,即r=(p-u)/u
,其中u是今天的实际价格,我有。我该如何编码?
例如:(我不分析pdf,这只是一个例子)
realPDF <- function(S) (1-S)^2
newPDF <- function(r) realPDF(r=(S-u)/u)
这对吗?
编辑:
怎么样:
realPDF <- function(S) (1-S)^2
r_t <- function(S) (S- u)/u]
newPDF <- function(r_t) realPDF(r_t)
答案 0 :(得分:0)
我试图用数字回答它,但效果很好:
x <- seq( min(S), max(S), 1) # The prices
y <- realPDF(x) # probablities of each price
rets <- (x- u)/u # create returns
tmp <- splinefun(rets , y= y) # define the function numerically with spline
PDF<- function(r_t) tmp(r_t) # define the PDF function
normalizer <- integrate( PDF , min(rets), max(rets)[[1]] # in order to integrate to one
newPDF <- function(r_t) PDF(r_t)/normalizer