News for hackers. Stuff that matters.
Re:Micromort by bo1024 on Friday June 19, 2020 @02:38PM (#23577544)
Here's a fun way to see this approximation: 1 + x ~= e^x when x is close to zero (either positive or negative).

So let m be 10^-6 .

Probability of survival of one event = 1 - m ~= e^-m .

Probability of survival of two events = (1 - m)^2 ~= (e^-m)^2 = e^-2m ~= 1 - 2m.

Re:Micromort by klodolph on Friday June 19, 2020 @03:28PM (#23578036)
To add to this, this is why we have those funny functions log1p() and expm1() in the standard library.

To add micromorts:

    double add_micromorts(double x, double y) {
        return -1e6 * expm1(
            -log1p(x * 1e-6) - log1p(y * 1e-6)
        );
    }
This is not the most accurate way of doing things, it is much simpler to

    return x + y - x * y * 1e-6;
But the formula with expm1 and log1p lets you easily do things like multiply 10 micromorts/day by 10.5 days.
Re:Micromort by smabie on Saturday June 20, 2020 @05:47AM (#23582913)
They're mostly there for converting from log returns and back, but yeah they're good for any kind of probabilities as well.