Given a function of x, i.e. \(f_X(x)\), compute its Esscher transform and return again a function of x.
desscher(pdf, theta = 0, lower = -Inf, upper = Inf)
pesscher(pdf, theta = 0, lower = -Inf, upper = Inf)A function of x.
Given a pdf \(f_X(x)\) the function computes its Esscher transform, i.e.
$$\mathcal{E}_{\theta}\{f_X(x)\} = \frac{e^{\theta x} f_X(x)}{\int_{-\infty}^{\infty} e^{\theta x} f_X(x) dx}$$
Version 1.0.0.
Other distributions:
desscherMixture(),
dgumbel(),
dinvgumbel(),
dkumaraswamy(),
dmixnorm(),
dsnorm(),
dsolarGHI(),
dsolarK(),
dsolarX(),
dsugeno(),
dtnorm()
# Grid of points
grid <- seq(-3, 3, 0.1)
# Density function of x
pdf <- function(x) dnorm(x, mean = 0)
# Esscher density (no transform)
esscher_pdf <- desscher(pdf, theta = 0)
pdf(grid) - esscher_pdf(grid)
#> [1] -9.122546e-13 -1.225273e-12 -1.629322e-12 -2.145051e-12 -2.795928e-12
#> [6] -3.608037e-12 -4.609705e-12 -5.830857e-12 -7.302117e-12 -9.053612e-12
#> [11] -1.111353e-11 -1.350640e-11 -1.625115e-11 -1.935913e-11 -2.283201e-11
#> [16] -2.665998e-11 -3.082001e-11 -3.527462e-11 -3.997139e-11 -4.484285e-11
#> [21] -4.980741e-11 -5.477119e-11 -5.963030e-11 -6.427459e-11 -6.859119e-11
#> [26] -7.246936e-11 -7.580497e-11 -7.850515e-11 -8.049250e-11 -8.170897e-11
#> [31] -8.211853e-11 -8.170897e-11 -8.049250e-11 -7.850515e-11 -7.580497e-11
#> [36] -7.246936e-11 -6.859119e-11 -6.427459e-11 -5.963030e-11 -5.477119e-11
#> [41] -4.980741e-11 -4.484285e-11 -3.997139e-11 -3.527462e-11 -3.082001e-11
#> [46] -2.665998e-11 -2.283201e-11 -1.935913e-11 -1.625115e-11 -1.350640e-11
#> [51] -1.111353e-11 -9.053612e-12 -7.302117e-12 -5.830857e-12 -4.609705e-12
#> [56] -3.608037e-12 -2.795928e-12 -2.145051e-12 -1.629322e-12 -1.225273e-12
#> [61] -9.122546e-13
# Esscher density (transform)
esscher_pdf_1 <- function(x) dnorm(x, mean = -0.1)
esscher_pdf_2 <- desscher(pdf, theta = -0.1)
esscher_pdf_1(grid) - esscher_pdf_2(grid)
#> [1] -1.419529e-12 -1.887629e-12 -2.485125e-12 -3.239194e-12 -4.180045e-12
#> [6] -5.340527e-12 -6.755270e-12 -8.459781e-12 -1.048896e-11 -1.287546e-11
#> [11] -1.564771e-11 -1.882759e-11 -2.242830e-11 -2.645180e-11 -3.088665e-11
#> [16] -3.570616e-11 -4.086703e-11 -4.630840e-11 -5.195216e-11 -5.770387e-11
#> [21] -6.345463e-11 -6.908407e-11 -7.446460e-11 -7.946571e-11 -8.395862e-11
#> [26] -8.782308e-11 -9.095130e-11 -9.325379e-11 -9.466306e-11 -9.513762e-11
#> [31] -9.466306e-11 -9.325379e-11 -9.095130e-11 -8.782308e-11 -8.395862e-11
#> [36] -7.946560e-11 -7.446466e-11 -6.908402e-11 -6.345457e-11 -5.770390e-11
#> [41] -5.195222e-11 -4.630846e-11 -4.086706e-11 -3.570622e-11 -3.088665e-11
#> [46] -2.645183e-11 -2.242831e-11 -1.882762e-11 -1.564772e-11 -1.287549e-11
#> [51] -1.048898e-11 -8.459802e-12 -6.755287e-12 -5.340530e-12 -4.180063e-12
#> [56] -3.239201e-12 -2.485134e-12 -1.887639e-12 -1.419529e-12 -1.056886e-12
#> [61] -7.790561e-13
# Esscher Distribution (transform)
esscher_cdf <- pesscher(pdf, theta = -0.1)
plot(esscher_cdf(grid))
#> Error in esscher_cdf(grid): object 'log.p' not found