←back to thread

Uncertain<T>

(nshipster.com)
444 points samtheprogram | 4 comments | | HN request time: 0.026s | source
Show context
j2kun ◴[] No.45056827[source]
This concept has been done many times in the past, under the name "interval arithmetic." Boost has it [1] as does flint [2]

What is really curious is why, after being reinvented so many times, it is not more mainstream. I would love to talk to people who have tried using it in production and then decided it was a bad idea (if they exist).

[1]: https://www.boost.org/doc/libs/1_89_0/libs/numeric/interval/... [2]: https://arblib.org/

replies(8): >>45056929 #>>45057194 #>>45057366 #>>45057865 #>>45058239 #>>45058375 #>>45058723 #>>45062336 #
kccqzy ◴[] No.45057366[source]
The article says,

> Under the hood, Uncertain<T> models GPS uncertainty using a Rayleigh distribution.

And the Rayleigh distribution is clearly not just an interval with a uniformly random distribution in between. Normal interval arithmetic isn't useful because that uniform random distribution isn't at all a good model for the real world.

Take for example that Boost library you linked. Ask it to compute (-2,2)*(-2,2). It will give (-4,4). A more sensible result might be something like (-2.35, 2.35). The -4 lower bound is only attainable when you have -2 and 2 as the multiplicands which are at the extremes of the interval; probabilistically if we assume these are independent random variables then two of them achieving this extreme value simultaneously should have an even lower probability.

replies(1): >>45060585 #
rendaw ◴[] No.45060585[source]
While it does sound like GP missed a distinction, I don't see how (-2.35, 2.35) would be sensible. The extremes can happen (or else they wouldn't be part of the input intervals) and the code has to sensibly deal with that event in order to be correct.
replies(3): >>45062972 #>>45064017 #>>45080705 #
1. kccqzy ◴[] No.45064017[source]
Interval arithmetic isn't useful because it only tells you the extreme values, but not how likely these values are. So you have to interpret them as uniform random. Operations like multiplications change the shape of these distributions, so then uniform random isn't applicable any more. Therefore interval arithmetic basically has an undefined underlying distribution that can change easily without being tracked.
replies(1): >>45065842 #
2. mcphage ◴[] No.45065842[source]
> Operations like multiplications change the shape of these distributions, so then uniform random isn't applicable any more.

Doesn't addition as well? Like if you roll d6+d6, the output range is 2-12, but it's not nearly the same as if you rolled d11+1.

replies(1): >>45066031 #
3. kccqzy ◴[] No.45066031[source]
Yes that's true! I used multiplication because that was my original example.
replies(1): >>45073853 #
4. mcphage ◴[] No.45073853{3}[source]
Okay, thanks :-). I was just trying to make sure I was understanding what I was reading.