Uncertain<T>

You know what’s wrong with people? They’re too sure of themselves.

Better to be wrong and own it than be right with caveats. Hard to build a personal brand out of nuance these days. People are attracted to confidence — however misplaced.

But can you blame them? (People, that is) Working in software, the most annoying part of reaching Senior level is having to say “it depends” all the time. Much more fun getting to say “let’s ship it and iterate” as Staff or “that won’t scale” as a Principal.

nshipster.com/uncertainty/

The provided text critiques the oversimplification in programming that ignores real-world uncertainties, particularly in handling noisy data like GPS coordinates, proposing a probabilistic approach using the Uncertain<T> type inspired by a 2014 research paper.

Implemented in Swift, Uncertain<T> models uncertainty with probability distributions (e.g., Rayleigh for GPS, normal for sensor data) and uses Monte Carlo sampling with Sequential Probability Ratio Testing for efficient computation, allowing operations like comparisons to return probabilistic results (Uncertain<Bool>) rather than definitive Booleans.

Examples include calculating running speed with uncertain time inputs and modelling slot machine payouts, with a companion project showcasing Swift Charts visualisations. The approach encourages acknowledging uncertainty in code to avoid misleading outcomes, advocating for gradual adoption in critical paths and performance profiling to manage computational costs.

It emphasises Swift’s suitability for such abstractions due to its generics and type safety, urging developers to integrate probabilistic modelling to enhance reliability in applications like location-based services.


Category:

Tag:

Year: