public final class Discounts extends Object
Definitions of different discount functions.
Modifier and Type | Method and Description |
---|---|
static ExponentialDiscount |
exp(double hl)
Create a new exponential (half-life) discount.
|
static LogDiscount |
log(double base)
Create a new logarithmic discount.
|
static LogDiscount |
log2()
Create a log-base-2 discount.
|
static Discount |
parse(String disc)
Parse a discount expression from a string.
|
public static LogDiscount log2()
Create a log-base-2 discount. The discount function is:
\[\mathrm{disc}(i) = \begin{cases} 1 & i \le 2 \\ (\mathrm{log}_{2} i)^{-1} & \mathrm{else} \end{cases} \]
public static LogDiscount log(double base)
Create a new logarithmic discount. The discount function is:
\[\mathrm{disc}(i) = \begin{cases} 1 & i \le b \\ (\mathrm{log}_{b} i)^{-1} & \mathrm{else} \end{cases} \]
base
- The log base $b$.public static ExponentialDiscount exp(double hl)
Create a new exponential (half-life) discount. The discount function is:
\[\mathrm{disc}(i) = \left(2^{\frac{i-1}{\alpha-1}}\right)^{-1}\]
hl
- The half-life $\alpha$ of the decay function.