Uncertain<T>

145 samtheprogram 20 8/28/2025, 5:22:54 PM nshipster.com ↗

Comments (20)

cb321 · 3m ago
[delayed]
AlotOfReading · 1h ago
A small note, but GPS is only well-approximated by a circular uncertainty in specific conditions, usually open sky and long-time fixes. The full uncertainty model is much more complicated, hence the profusion of ways to measure error. This becomes important in many of the same situations that would lead you to stop treating the fix as a point location in the first place. To give a concrete example, autonomous vehicles will encounter situations where localization uncertainty is dominated by non-circular multipath effects.

If you go down this road far enough you eventually end up reinventing particle filters and similar.

mikepurvis · 26m ago
Vehicle GPS is usually augmented by a lot of additional sensors and assumptions, notably the speedometer, compass, and knowledge the you'll be on one of the roads marked on its map. Not to mention a fast fix because you can assume you haven't changed position since you last powered on.
8note · 15m ago
for mechanical engineering drawings to communicate with machinists and the like, we use tolerances

eg. 10cm +8mm/-3mm

for what the acceptable range is, both bigger and smaller.

id expect something like "are we there yet" referencing GPS should understand the direction of the error and what directions of uncertainty are better or worse

layer8 · 1h ago
Arguably Uncertain should be the default, and you should have to annotate a type as certain T when you are really certain. ;)
nine_k · 5m ago
Only for physical measurements. For things like money, you should be pretty certain, often down to exact fractional cents.

It appears that a similar approach is implemented in some modern Fortran libraries.

esafak · 36m ago
A complement to Optional.
boscillator · 1h ago
Does this handle covariance between different variables? For example, the location of the object your measuring your distance to presumably also has some error in it's position, which may be correlated with your position (if, for example, if it comes from another GPS operating at a similar time).

Certainly a univarient model in the type system could be useful, but it would be extra powerful (and more correct) if it could handle covariance.

evanb · 22m ago
If you need to track covariance you might want to play with gvar https://gvar.readthedocs.io/en/latest/ in python.
layer8 · 59m ago
To properly model quantum mechanics, you’d have to associate a complex-valued wave function with any set of entangled variables you might have.
munchler · 46m ago
Is this essentially a programmatic version of fuzzy logic?

https://en.wikipedia.org/wiki/Fuzzy_logic

esafak · 35m ago
https://en.wikipedia.org/wiki/Probabilistic_programming more like. It is already a thing; see, for example, https://pyro.ai/
mackross · 1h ago
Always enjoy mattt’s work. Looks like a great library.
krukah · 44m ago
Monads are really undefeated. This particular application feels to me akin to wavefunction evolution? Density matrices as probability monads over Hilbert space, with unitary evolution as bind, measurement/collapse as pure/return. I guess everything just seems to rhyme under a category theory lens.
valcron1000 · 26m ago
jakubmazanec · 1h ago
[flagged]
muxl · 1h ago
It was chosen to be implemented as a generic type in this design because the way that uncertainty "pollutes" underlying values maps well onto monads which were expressed through generics in this case.
frizlab · 1h ago
> And why does it need to be part of the type system?

As presented in the article, it is indeed just a library.

geocar · 1h ago
> What if I want Bayesian?

Bayes is mentioned on page 46.

> And why does it need to be part of the type system? It could be just a library.

It is a library that defines a type.

It is not a new type system, or an extension to any particularly complicated type system.

> Am I missing something?

Did you read it?

https://www.microsoft.com/en-us/research/wp-content/uploads/...

https://github.com/klipto/Uncertainty/

jakubmazanec · 59m ago
> Bayes is mentioned on page 46.

Bayes isn't mentioned in the linked article. But thanks for the links.

cobbal · 1h ago
I don't think inference is part of this at all, frequentist or otherwise.

It's not part of the type system, it's just the giry monad as a library.