View source: R/Central_tendencies.R
NNS.rescale | R Documentation |
Rescale a vector using either min-max scaling or risk-neutral adjustment.
NNS.rescale(x, a, b, method = "minmax", T = NULL, type = "Terminal")
x |
numeric vector; data to rescale (e.g., terminal prices for risk-neutral method). |
a |
numeric; defines the scaling target:
- For |
b |
numeric; defines the scaling range or rate:
- For |
method |
character; scaling method: |
T |
numeric; time to maturity in years (required for |
type |
character; for |
Returns a rescaled distribution:
- For "minmax"
: values scaled linearly to the range [a, b]
.
- For "riskneutral"
: values scaled multiplicatively to a risk-neutral mean (\( S_0 e^(rT) \) if type = "Terminal"
, or \( S_0 \) if type = "Discounted"
).
Fred Viole, OVVO Financial Systems
## Not run:
set.seed(123)
# Min-max scaling: a = lower limit, b = upper limit
x <- rnorm(100)
NNS.rescale(x, a = 5, b = 10, method = "minmax") # Scales to [5, 10]
# Risk-neutral scaling (Terminal): a = S_0, b = r # Mean approx 105.13
prices <- 100 * exp(cumsum(rnorm(100, 0.001, 0.02)))
NNS.rescale(prices, a = 100, b = 0.05, method = "riskneutral", T = 1, type = "Terminal")
# Risk-neutral scaling (Discounted): a = S_0, b = r # Mean approx 100
NNS.rescale(prices, a = 100, b = 0.05, method = "riskneutral", T = 1, type = "Discounted")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.