QUANTLAB / QUANTITATIVE WORKBENCH

Math Verification

INTERNAL

Every shared routine is checked against a value that can be worked out by hand or from a textbook.

Passed

36 / 36

Failed

0

Statistics

CheckExpectedActualResult
mean([2,4,4,4,5,5,7,9])5.0000005.000000PASS
std (population)2.0000002.000000PASS
std (sample)2.1380902.138090PASS
cov(x, x) = var(x)4.5714294.571429PASS
corr(x, 2x+1) = 11.0000001.000000PASS
corr(x, -x) = -1-1.000000-1.000000PASS
skewness (symmetric set)0.0000000.000000PASS
excess kurtosis of uniform 1..9-1.230000-1.230000PASS
quantile(0.5) of 1..53.0000003.000000PASS
quantile(0.25) of 1..52.0000002.000000PASS

Linear algebra

CheckExpectedActualResult
Cholesky L[0][0] of textbook matrix2.0000002.000000PASS
Cholesky L[2][2]3.0000003.000000PASS
L·Lᵀ reproduces A[1][2]-43.000000-43.000000PASS
inverse([[4,7],[2,6]])[0][0]0.6000000.600000PASS
inverse([[4,7],[2,6]])[0][1]-0.700000-0.700000PASS
matVec row 139.00000039.000000PASS

Normal

CheckExpectedActualResult
pdf(0) = 1/√(2π)0.3989420.398942PASS
cdf(0)0.5000000.500000PASS
cdf(1.96)0.9750020.975002PASS
cdf(-2.33)0.0099030.009903PASS
inverse cdf(0.975)1.9599641.959963PASS
inverse cdf(0.01)-2.326348-2.326347PASS
round trip cdf(inv(0.3))0.3000000.300000PASS

Random

CheckExpectedActualResult
MT19937 normal sample mean ≈ 00.000000-0.000334PASS
MT19937 normal sample std ≈ 11.0000001.000534PASS
same seed reproduces the same draw0.0000000.000000PASS
uniform sample mean ≈ 0.50.5000000.499497PASS

Regression

CheckExpectedActualResult
OLS intercept of y = 3x + 22.0000002.000000PASS
OLS slope of y = 3x + 23.0000003.000000PASS
OLS R² of exact fit1.0000001.000000PASS

Time series

CheckExpectedActualResult
ADF rejects a unit root for a mean-reverting OU seriesstatistic < -2.86statistic = -4.258PASS
ADF fails to reject for a random walkstatistic > -2.86statistic = -1.652PASS
OU half-life is short (κ = 6/yr ⇒ ≈ 29 days)between 10 and 60 days30.80 daysPASS

Generators

CheckExpectedActualResult
GBM asset A annualised vol ≈ 20%0.2000000.198179PASS
GBM asset B annualised vol ≈ 30%0.3000000.297578PASS
GBM realised correlation ≈ 0.600.6000000.610961PASS