I would like to compute some scipy functions, such as: scipy.special.gammaincinv
(https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.gammaincinv.html#scipy.special.gammaincinv).
The challenge, however, is that one of the arguments I need to use is 1 - a
where a
is a very small number, a=1e-18
in this case.
Therefore, as Python's small number precision is limited to about 1e-15, Python computes 1 - a
= 1 - 1e-18
= 1.0, i.e. it's inaccurate.
I could use libraries like mpmath
to get an accurate calculation of 1 - a
but then the returned object is not a normal number, so can't be passed to numpy / scipy functions.
Therefore, my question is: how best to use scipy & numpy functions when the input numbers include precision beyond that of standard floats (ideally, not simply rewriting the functions themselves using mpmath-type constructs?)
EDIT:
The exact expression I want to calculate is: gammaincinv(10, 1-a)
where a
is a very small number (a=1e-18
). Due to limited precision, 1-a
is calculated as 1.0, which gives the wrong value.