boppreh / carlo

Interactively plot streaming sequences of numbers
MIT License
9 stars 0 forks source link

Feature idea: Cumulative probability #1

Open mast4461 opened 3 years ago

mast4461 commented 3 years ago

Hi! Very cool software. :)

Here's a feature idea that might be useful in many situations:

It is often of interest to know the probability that the outcome of some random event is above or below some threshold, or sometimes in between two thresholds. More generally one might be interested in the likelihood that the outcome is in any of a set of intervals. A type of dual question to this is "given a certain likelihood threshold, what is the maximum/minimum value?".

Maybe this kind of question could be quickly answered within the tool by "painting" over the histogram to select columns, and displaying the sum of selected columns. Another option might be to extend the input syntax somehow, but that avenue gives less explorative power to the user.

Another partial solution is to additionally show a histogram of the cumulative sum.

I just wanted to give some praise and share some ideas. Take care! :)

boppreh commented 3 years ago

Nice idea!

Maybe this kind of question could be quickly answered within the tool by "painting" over the histogram to select columns, and displaying the sum of selected columns.

That's definitely doable. MatPlotLib's interactive elements are not very customizable, but I can detect when the user zooms in an area and display the total likelihood in the legend.

A type of dual question to this is "given a certain likelihood threshold, what is the maximum/minimum value?".

That's a bit harder to do interactively, but could be a parameter to the function. The range is already displayed in the legend, but with a range of 100% (the single largest and smallest values seen). Note that switching to a probabilistic threshold will lose precision on the range, since it'll have to be calculated based on the bins and not the exact max/min values seen.

Another partial solution is to additionally show a histogram of the cumulative sum.

I'd have to think more about this one, it's a bit hard to visualize all the use cases here.

mast4461 commented 3 years ago

A type of dual question to this is "given a certain likelihood threshold, what is the maximum/minimum value?".

That's a bit harder to do interactively, but could be a parameter to the function. The range is already displayed in the legend, but with a range of 100% (the single largest and smallest values seen). Note that switching to a probabilistic threshold will lose precision on the range, since it'll have to be calculated based on the bins and not the exact max/min values seen.

Oh, I was thinking that the proposed paint-over functionality could be used to give rough answers to questions like this, as is. For example, let's say you are to throw three D6, and for some reason want to know what is the maximum value that gives a, say, 70% chance of success? This can be answered by painting over bars starting from the right until the sum reaches 70%, at which point the position of the leftmost painted over bar indicates the value X. Then you can say "There's a 70% chance that I'll get at least X".

So instead of asking "how big is the chance that I get at least X" you're asking "what is X such that I have a specific chance of success Y". A slightly different question, but answerable with the same functionality.