I was working on writing more tests and the hypothesis library found this example where the logcdf method wasn't accurate with the quadrature method. Here is the script
import numpy as np
from normal import Normal
if __name__ == '__main__':
arg = -0.55686482
methods = ['formula', 'log/exp', 'quadrature']
X = Normal(mu=0.904775196502295, sigma=1.3102019638947042)
reference = np.exp(X.logcdf(arg))
print("-------------------")
for method in methods:
result = np.exp(X.logcdf(arg, method=method))
print(f"Method: {method}", "\n"
"Absolute difference: ", np.abs(reference - result), "\n"
"-------------------")
and the output is
-------------------
Method: formula
Absolute difference: 0.0
-------------------
Method: log/exp
Absolute difference: 1.1102230246251565e-16
-------------------
Method: quadrature
Absolute difference: 1.3001154173353235e-05
-------------------
The relative tolerance is currently set to 1e-7 so this doesn't pass. It's not as if this is in the tail so I don't understand why the accuracy isn't that great.
I was working on writing more tests and the hypothesis library found this example where the
logcdfmethod wasn't accurate with thequadraturemethod. Here is the scriptand the output is
The relative tolerance is currently set to
1e-7so this doesn't pass. It's not as if this is in the tail so I don't understand why the accuracy isn't that great.