otbenchmark.ReliabilityLibrary.ComputeLogRelativeError

ComputeLogRelativeError(exact, computed, basis=10.0)

Compute the log-relative error between exact and computed.

The log-relative error (LRE) is defined by:

LRE = -logB(relativeError)

where relativeError is the relative error:

relativeError = abs(exact - computed) / abs(exact)

and logB is the base-b logarithm:

logB(x) = log(x) / log(basis)

where log is the natural logarithm. This assumes that exact is different from zero.

The LRE is the number of base-B common digits in exact and computed, if the exponents are the same. Otherwise, the LRE can be large (i.e. the number of “common digits” can be large), even if the digits are very different. For example, if exact = 1.00000000000 and computed = 0.99999999999, then LRE = 11 even if there is no common digits in the two real numbers.

Parameters:
exact: float

The exact value.

computed: float

The computed value.

Returns:
logRelativeError: float

The LRE. The maximum possible LRE is 15.65. The minimum possible LRE is 0.

Examples

>>> import otbenchmark as otb
>>> benchmarkProblemList = otb.ReliabilityBenchmarkProblemList()
>>> numberOfProblems = len(benchmarkProblemList)
>>> for i in range(numberOfProblems):
...     problem = benchmarkProblemList[i]
...     name = problem.getName()
...     pf = problem.getProbability()
...     print("#", i, " : ", name, ", exact PF : ", pf)