org.lenskit.eval.traintest.metrics

## Class Discounts

• java.lang.Object
• org.lenskit.eval.traintest.metrics.Discounts

• public final class Discounts
extends java.lang.Object

Definitions of different discount functions.

• ### Method Summary

All Methods
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(java.lang.String disc)
Parse a discount expression from a string.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Method Detail

• #### log2

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}$

Returns:
The discount.
• #### log

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}$

Parameters:
base - The log base $b$.
Returns:
The discount.
• #### exp

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}$

Parameters:
hl - The half-life $\alpha$ of the decay function.
Returns:
The discount.
• #### parse

public static Discount parse(java.lang.String disc)

Parse a discount expression from a string.

Parameters:
disc - The discount string.
Returns:
The discount.