I like this!<p>In the grand HN tradition of being triggered by a word in the post and going off on a not-quite-but-basically-totally-tangential rant:<p>There’s (at least) three areas here that are footguns with these kinds of calculations:<p>1) 95% is usually a lot wider than people think - people take 95% as “I’m pretty sure it’s this,” whereas it’s really closer to “it’d be really surprising if it were not this” - by and large people keep their mental error bars too close.<p>2) probability is rarely truly uncorrelated - call this the “Mortgage Derivatives” maxim. In the family example, rent is very likely to be correlated with food costs - so, if rent is high, food costs are also likely to be high. This skews the distribution - modeling with an unweighted uniform distribution will lead to you being surprised at how improbable the actual outcome was.<p>3) In general normal distributions are rarer than people think - they tend to require some kind of constraining factor on the values to enforce. We see them a bunch in nature because there tends to be negative feedback loops all over the place, but once you leave the relatively tidy garden of Mother Nature for the chaos of human affairs, normal distributions get pretty abnormal.<p>I like this as a tool, and I like the implementation, I’ve just seen a lot of people pick up statistics for the first time and lose a finger.
I have written similar tools<p>- for command line, fermi: <a href="https://git.nunosempere.com/NunoSempere/fermi" rel="nofollow">https://git.nunosempere.com/NunoSempere/fermi</a><p>- for android, a distribution calculator: <a href="https://f-droid.org/en/packages/com.nunosempere.distributioncalculator/" rel="nofollow">https://f-droid.org/en/packages/com.nunosempere.distribution...</a><p>People might also be interested in <a href="https://www.squiggle-language.com/" rel="nofollow">https://www.squiggle-language.com/</a>, which is a more complex version (or possibly <<a href="https://git.nunosempere.com/personal/squiggle.c" rel="nofollow">https://git.nunosempere.com/personal/squiggle.c</a>>, which is a faster but much more verbose version in C)
This is neat! If you enjoy the write up, you might be interested in the paper “Dissolving the Fermi Paradox” which goes even more on-depth into actually multiplying the probability density functions instead of the common point estimates. It has the somewhat surprising result that we may just be alone.<p><a href="https://arxiv.org/abs/1806.02404" rel="nofollow">https://arxiv.org/abs/1806.02404</a>
I have made a similar tool but for the command line[1] with similar but slightly more ambitious motivation[2].<p>I really like that more people are thinking in these terms. Reasoning about sources of variation is a capability not all people are trained in or develop, but it is increasingly important.[3]<p>[1]: <a href="https://git.sr.ht/~kqr/precel" rel="nofollow">https://git.sr.ht/~kqr/precel</a><p>[2]: <a href="https://entropicthoughts.com/precel-like-excel-for-uncertain-values" rel="nofollow">https://entropicthoughts.com/precel-like-excel-for-uncertain...</a><p>[3]: <a href="https://entropicthoughts.com/statistical-literacy" rel="nofollow">https://entropicthoughts.com/statistical-literacy</a>
The ASCII art (well technically ANSI art) histogram is neat. Cool hack to get something done quickly. I'd have spent 5x the time trying various chart libraries and giving up.
Is there a way to do non-scalar multiplication? E.g if I want to say "what is the sum of three dice rolls" (ignoring the fact that that's not a normal distro) I want to do 1~6 * 3 = 1~6 + 1~6 + 1~6 = 6~15. But instead it does 1~6 * 3 = 3~18. It makes it really difficult to do something like "how long will it take to complete 1000 tasks that each take 10-100 days?"
Would be nice to retransform the output into an interval / gaussian distribution<p><pre><code> Note: If you're curious why there is a negative number (-5) in the histogram, that's just an inevitable downside of the simplicity of the Unsure Calculator. Without further knowledge, the calculator cannot know that a negative number is impossible
</code></pre>
Drake Equation or equation multiplying probabilities can also be seen in log space, where the uncertainty is on the scale of each probability, and the final probability is the product of exponential of the log probabilities. And we wouldnt have this negative issue
It sounds like a gimmick at first, but looks surprisingly useful. I'd surely install it if it was available as an app to use alongside my usual calculator, and while I cannot quite recall a situation when I needed it, it seems very plausible that I'll start finding use cases once I have it bound to some hotkey on my keyboard.
I perused the codebase but I'm unfamiliar with dart:<p><a href="https://github.com/filiph/unsure/blob/master/lib/src/calculation.dart">https://github.com/filiph/unsure/blob/master/lib/src/calcula...</a><p>I assume this is a montecarlo approach? (Not to start a flamewar, at least for us data scientists :) ).
Here (<a href="https://uncertainty.nist.gov/" rel="nofollow">https://uncertainty.nist.gov/</a>) is another similar Monte Carlo-style calculator designed by the statisticians at NIST. It is intended for propagating uncertainties in measurements and can handle various different assumed input distributions.
Smol Show HN thread a few years ago <a href="https://news.ycombinator.com/item?id=22630600">https://news.ycombinator.com/item?id=22630600</a>
Also very very good is Guesstimate - <a href="https://www.getguesstimate.com/" rel="nofollow">https://www.getguesstimate.com/</a>.
Interval/affine arithmetic are alternatives which do not make use of probabilities for this these kinds of calculations.<p><a href="https://en.wikipedia.org/wiki/Interval_arithmetic" rel="nofollow">https://en.wikipedia.org/wiki/Interval_arithmetic</a><p>I think arbitrary distribution choice is dangerous. You're bound to end up using lots of quantities that are integers, or positive only (for example). "Confidence" will be very difficult to interpret.<p>Does it support constraints on solutions? E.g. A = 3~10, B = 4 - A, B > 0
<a href="https://qalculate.github.io" rel="nofollow">https://qalculate.github.io</a> can do this also for as long as I've used it (only a couple years to be fair). I've got it on my phone, my laptop, even my server with apt install qalc. Super convenient, supports everything from unit conversion to uncertainty tracking<p>The histogram is neat, I don't think qalc has that. On the other hand, it took 8 seconds to calculate the default (exceedingly trivial) example. Is that JavaScript, or is the server currently very busy?
I actually stumbled upon this a while ago from social media and the web version has a somewhat annoying latency, so I wrote my own version in Python. It uses numpy so it's faster. <a href="https://gist.github.com/kccqzy/d3fa7cdb064e03b16acfbefb76645744" rel="nofollow">https://gist.github.com/kccqzy/d3fa7cdb064e03b16acfbefb76645...</a> Thank you filiph for this brilliant idea!
On the whole it seems like a nice idea, but there's a couple of weird things, such as:<p>> Note: If you're curious why there is a negative number (-5) in the histogram, that's just an inevitable downside of the simplicity of the Unsure Calculator. Without further knowledge, the calculator cannot know that a negative number is impossible (in other words, you can't have -5 civilizations, for example).<p>The input to this was "1.5~3 x 0.9~1.0 x 0.1~0.4 x 0.1~1.0 x 0.1~1.0 x 0.1~0.2 x 304~10000" - every single range was positive, so regardless of what this represents, it should be impossible to get a negative result.<p>I guess this is a consequence of "I am not sure about the exact number here, but I am 95% sure it's somewhere in this range" so it's actually considering values outside of the specified range. In this case, 10% either side of all the ranges is positive except the large "304~10000".<p>Trying with a simpler example: "1~2 x 1~2" produces "1.3~3.4" as a result, even though "1~4" seems more intuitive. I assume this is because the confidence of 1 or 4 is now only 90% if 1~2 was at 95%, but it still feels off.<p>I wonder if the 95% thing actually makes sense, but I'm not especially good at stats, certainly not enough to be sure how viable this kind of calculator is with a tighter range. But just personally, I'd expect "1~2" to mean "I'm obviously not 100% sure, or else I wouldn't be using this calculator, but for this experiment assume that the range is definitely within 1~2, I just don't know where exactly".
This is awesome. I used Causal years ago to do something similar, with perhaps slightly more complex modelling, and it was great. Unfortunately the product was targeted at high paying enterprise customers and seems to have pivoted into finance now, I've been looking for something similar ever since. This probably solves at least, err... 40~60% of my needs ;)
This reminds me of <a href="https://www.getguesstimate.com/" rel="nofollow">https://www.getguesstimate.com/</a> , a probabilistic spreadsheet.
If I am reading this right, a range is expressed as a distance between the minimum and maximum values, and in the Monte Carlo part a number is generated from a uniform distribution within that range[1].<p>But if I just ask the calculator "1~2" (i.e. just a range without any operators), the histogram shows what looks like a normal distribution centered around 1.5[2].<p>Shouldn't the histogram be flat if the distribution is uniform?<p>[1] <a href="https://github.com/filiph/unsure/blob/123712482b7053974cbef9ffa7ba46c1cdfb765f/lib/src/range.dart#L27">https://github.com/filiph/unsure/blob/123712482b7053974cbef9...</a><p>[2] <a href="https://filiph.github.io/unsure/#f=1~2" rel="nofollow">https://filiph.github.io/unsure/#f=1~2</a>
Very cool. This can also be used for LLM cost estimation. Basically any cost estimation I suppose. I use cloudflare workers a lot and have a few workers running for a variable amount of time. This could be useful to calculate a ball park figure of my infra cost. Thank you!
An alternative approach is using fuzzy-numbers. If evaluated with interval arithmetic you can do very long calculations involving uncertain numbers very fast and with strong mathematical guarantees.<p>It would especially outperform the Monte-Carlo approach drastically.
Love it! I too have been toying with reasoning about uncertainty. I took a much less creative approach though and just ran a bunch of geometric brownian motion simulations for my personal finances [0]. My approach has some similarity to yours, though much less general. It displays the (un)certainty over time (using percentile curves), which was my main interest. Also, man, the UI, presentation, explanations: you did a great job, pretty inspiring.<p>[0] <a href="https://dmos62.github.io/personal-financial-growth-simulator/" rel="nofollow">https://dmos62.github.io/personal-financial-growth-simulator...</a>
The histogram is great, nice work;<p>I want to ask about adjacent projects - user interface libraries that provide input elements for providing ranges and approximate values. I'm starting my search around <a href="https://www.inkandswitch.com/" rel="nofollow">https://www.inkandswitch.com/</a> and <a href="https://malleable.systems/catalog/" rel="nofollow">https://malleable.systems/catalog/</a> but I think our collective memory has seen more examples.
There's an amazing scene in "This is Spinal Tap" where Nigel Tufnel had been brainstorming a scene where Stonehenge would be lowered from above onto the stage during their performance, and he does some back of the envelope calculations which he gives to the set designer. Unfortunately, he mixes the symbol for feet with the symbol for inches. Leading to the following:<p><a href="https://www.youtube.com/watch?v=Pyh1Va_mYWI" rel="nofollow">https://www.youtube.com/watch?v=Pyh1Va_mYWI</a>
Cool! Some random requests to consider: Could the range x~y be uniform instead of 2 std dev normal (95.4%ile)? Sometimes the range of quantities is known. 95%ile is probably fine as a default though.
Also, could a symbolic JS package be used instead of Monte-Carlo? This would improve speed and precision, especially for many variables (high dimensions).
Could the result be shown in a line plot instead of ASCII bar chart?
Cool. It would be great to extend with a confidence operator. Something like:<p>Without default confidence:
0~9<p>With confidence:
0%100~9%95<p>We are sure it is 0 or more and we are %95 certain it is 9 or less.<p>Would that work?
I made one that's much faster because it instead modifies the normal distribution instead of sending thousands of samples: <a href="https://gistpreview.github.io/?757869a716cfa1560d6ea0286ee1b56b" rel="nofollow">https://gistpreview.github.io/?757869a716cfa1560d6ea0286ee1b...</a>
Interesting. I like the notation and the histogram that comes out with the output. I also like the practical examples you gave (e.g. the application of the calculator to business and marketing cases). I will try it out with simple estimates in my marketing campaigns.
Chalk also supports uncertainty : <a href="https://chachatelier.fr/chalk/chalk-features.php" rel="nofollow">https://chachatelier.fr/chalk/chalk-features.php</a> (combined with arbitrary long numbers and interval arithmetic)
This is really useful, but is this correct?<p>persons = 10~15
// → 10~15<p>budget = persons * 1~2
// → 12~27<p>Should it not say 10-30?
”Without further knowledge, the calculator cannot know that a negative number is impossible (in other words, you can't have -5 civilizations, for example).”<p>Not true. If there are no negative terms, the equation cannot have negative values.
Really cool! On iOS there's a noticeable delay when clicking the buttons and clicking the backspace button quickly zooms the page so it's very hard to use. Would love it in mobile friendly form!
This reminded me of this submission a few days ago: Napkin Math Tool[1].<p>[1]: <a href="https://news.ycombinator.com/item?id=43389455">https://news.ycombinator.com/item?id=43389455</a>
So is it like plugging in a normal distribution into some arithmetic?<p>Consider maybe 1 + 1 ~ +-2 like Q factor, if you know what I mean.<p>That would help to filter out more probabilistic noise in using it to help reason with.
So is it 250k calculations for every approximation window ? So i guess it will only be able to calculate upto 3-4 approximations comfortably ?<p>Any reason why we kept it 250k and now a lower number like 10k
I love this! As a tool for helping folks with a good base in arithmetic develop statistical intuition, I can't think offhand of what I've seen that's better.
> The UI is ugly, to say the least.<p>I actually quite like it. Really clean, easy to see all the important elements. Lovely clear legible monospace serif font.
See also Guesstimate <a href="https://getguesstimate.com" rel="nofollow">https://getguesstimate.com</a>. Strengths include treating label and data as a unit, a space for examining the reasoning for a result, and the ability to replace an estimated distribution with sample data => you can build a model and then refine it over time. I'm amazed Excel and Google Sheets still haven't incorporated these things, years later.
This is super cool.<p>It seems to break for ranges including 0 though<p>100 / -1~1 = -3550~3500<p>I think the most correct answer here is -inf~inf
similar to guesstimate, which does the same but for spreadsheets: <a href="https://www.getguesstimate.com/" rel="nofollow">https://www.getguesstimate.com/</a>
I think the SWI Prolog clpBNR package is the most complete interval arithmetic system. It also supports arbitrary constraints.<p><a href="https://github.com/ridgeworks/clpBNR">https://github.com/ridgeworks/clpBNR</a>
i like it and i skimmed the post but i don't understand why the default example 100 / 4~6 has a median of 20? there is no way of knowing why the range is between 4 and 6