KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am performing a probability computation. I have many very very small numbers, all of which I want to subtract from 1, and do so accurately. I can accurately compute the logarithm of these small numbers. My strategy so far has been like so (using numpy): Given an array of the log of the small numbers x , compute: y = numpy.logaddexp.reduce(x) Now I want to compute something like 1-exp(y) or even better log(1-exp(y)) , but I'm not sure how to do so without losing all my precision. In fact, even the logaddexp function is running into precision problems. Values in the vector x can range from -2 through -800, or even more negative. The vector y from above would basically have a whole section of numbers around 1e-16, which is the eps of the data type. So, for example, the accurately computed data could look like this: In [358]: x Out[358]: [-5.2194676211172837, -3.9050377656308362, -3.1619783292449615, -2.71289594096134, -2.4488395891021639, -2.3129210706827568, -2.2709987626652346, -2.3007776073511259, -2.3868404149802434, -2.5180718876609163, -2.68619816583087, -2.8849022632856958, -3.1092603032627686, -3.3553673369747834, -3.6200806272462351, -3.9008385919463073, -4.1955300857178379, -4.5023981074719899, -4.8199676154248081, -5.1469905756384904, -5.4824035553480428, -5.8252945959126876, -6.174877049340779, -6.5304687083067563, -6.8914750074202473, -7.25737538919104, -7.6277121540338797, -8.0020812775389558, -8.3801247986220773, -8.7615244716292437, -9.1459964426584435, -9.5332867613176404, -9.9231675781398394, -10.315433907978701, -10.709900863130784, -11.106401278287066, -11.50478366390567, -11.904910436107656, -12.30665638039909, -12.709907313918777, -13.114558916892051, -13.52051570882999, -13.927690148982549, -14.336001843810081, -14.745376846921289, -15.15
Tags (comma-separated)
Save Edits
Cancel