Showing posts with label probability. Show all posts
Showing posts with label probability. Show all posts

Friday, August 03, 2018

Bayesian Reasoning: Discrete Inference with Sequential Data

Or, One Way I Learned to Quit Believing My Prejudices

In my last article on this topic, I showed that considering background information can play a significant role in helping us make less biased judgments. What I hope to show now is that while we learn by updating the information we have through experience, limited experiences can often lead to prejudices about the way we interpret the world; but even broad and deep experience should rarely lead us to certain conclusions.

To get started, imagine playing a game in which someone asks you to infer the number of sides of a die based on the face numbers that show up in repeated throws of the die. The only information you are given beforehand is that the actual die will be selected from a set of seven die having these number of faces: (4, 6, 8, 10, 12, 15, 18). Assuming you can trust the person who reports the outcome on each throw, after how many rolls of the die will you be willing to specify which die was chosen?

Let's use the R programming language to help us think through the problem. Start by specifying the set of the die possibilities such that each number represents the number of sides of a given die. (You might also want to refer to my previous article on Bayesian analysis to familiarize yourself with some of the terminology that follows.)

To read the entire discussion go here.

Friday, August 04, 2017

Bayesian Reasoning: Gender Inference from a Specimen Measurement

Imagine that we have a population of something composed of two subset populations that, while distinct from each other, share a common characteristic that can be measured along some kind of scale. Furthermore, let’s assume that each subset population expresses this characteristic with a frequency distribution unique to each. In other words, along the scale of measurement for the characteristic, each subset displays varying levels of the characteristic among its members. Now, we choose a specimen from the larger population in an unbiased manner and measure this characteristic for this specific individual. Are we justified in inferring the subset membership of the specimen based on this measurement alone? Baye’s rule (or theorem), something you may have heard about in this age of exploding data analytics, tells us that we can be so justified as long as we assign a probability (or degree of belief) to our inference. The following discussion provides an interesting way of understanding the process to do this. More importantly, I present how Baye’s theorem helps us overcome a common thinking failure associated with making inferences from an incomplete treatment of all the information we should use. I’ll use a bit of a fanciful example to convey this understanding along with showing the associated calculations in the R programming language.

Suppose we are aliens from another planet conducting scientific research on this strange group of bipedal organisms called humans...



To read the entire discussion go here.

Wednesday, January 07, 2015

An Interesting Christmas Gift

Over the holidays, the New York Times delivered an unusual juxtaposition of headlines and content, and apparent lack of self-awareness, to illicit such a hearty chuckle from its readers as to make the cheerful Old Saint jealous.


[image originally provided by @ddmeyer on Twitter]

To those imbued with the skill of basic high school Algebra 1, the information in the article about Sony’s revenues for the first four days of release of “The Interview” were enough to solve a unit value problem. If we let R = the number of rentals, and S = the number of sales; then,
  • R + S = 2 million 
  • $6*R + $15*S = $15 million 
With a little quick symbolic manipulation, we see that S = 1/3 million in sales and R = 5/3 million in rentals. That exercise provided just enough mental stimulation and smug self-righteousness to prepare for the day’s sudoku and crossword puzzles. #smug #math

However, not too far into the sudoku puzzle we might realize that a deeper, more instructive problem exists here, a problem that actually permeates all of our daily lives. That problem is related to the precision of the information we have to deal with in planning exercises or, say, garnering market intelligence, etc. A second reading of the article reveals that the sales values, both the total transactions and the total value of them, were reported as approximations. In other words, if the sources at Sony followed some basic rules of rounding, the total number of transactions could range from 1.5 million to 2.4 million, and the total value might range from $14.5 million to $15.4 million. This might not seem like a problem at first consideration. After all, 2 million is in the middleish of its rounding range as is $15 million. Certainly the actual values determined by the simple algebra above point to a good enough approximate answer. Right? Right?

To see if this true, let’s reassign the formulas above in the following way.
  • R + S = T 
  • $6*R + $15*S = V 
where T = total transactions, and V = total value. Again, with some quick symbolic manipulation, we can get the exactly precise answers for R and T across a range of values for T and V.
  • S = 1/9 * V - 2/3 * T 
  • R = T - S 
Doing this we now notice something quite at odds with our intuition - the range of variation between the sales and rentals can be quite large as we see in this scatter plot:



[Fig. 1: The distribution of total transaction values for various combinations of rental and direct sales numbers.]

Here we see that the rental numbers could range from about 800 thousand to 2.4 million, while the direct sales could range from nearly 0 to 700 thousand! Maybe more instructive is to consider the range of the ratio of the rentals to direct sales:


[Fig. 2: The distribution of the ratio of rentals to direct sales for various combinations of rental and direct sales numbers.]

If we blithely assume that the reported values of sales were precise enough to support believing that the actual value of rentals and unit sales were close to our initial result, we could be astoundingly wrong. The range of this ratio could run from about 1.11 (for 1.5 million in total transactions; 15.4 million in sales) to 215 (for 2.4 million in total transactions; 14.5 million in sales). If we were trying to glean market intelligence from these numbers on which to base our own operational or marketing activities, we would face quite a conundrum. What’s the best estimate to use?
Fortunately, we can turn to probabilisitic reasoning to help us out. Let’s say we consult a subject matter expert (SME) who gives us a calibrated range and distribution for the sales assumptions such that the range of each distribution stays mostly within the rounding range we specify.

[Fig. 2a, b: The hypothetical distribution of the (a) total sales transactions and (b) total value assessed by our SME.]

Using the sample values underlying these distributions in our last set of formulas, we observe that in all likelihood - an 80th percentile likelihood – the actual ratio of the rentals to sales falls in a much narrower range – the range of 3 to 9, not 1.11 to 215.

[Fig. 3: The 80th percentile prediction interval for the ratio of the rentals to sales falls in the range of 3 to 9.]

Our manager may push back on this by saying that our SME doesn’t really have the credibility to use the distributions assessed above. She asks, "What if we stick with maximal uncertainty within the range?” In other words, what if, instead of assessing a central tendency around the reported values with declining tails on each side, we assume there is a uniform distribution along the range of sales values (i.e., each value is equally probable to all values in the range)?



[Fig. 4a, b: We replace our SME supplied distribution for (a) total sales transactions and (b) total value with one that admits an insufficient reason to suspect that any value in our range is more likely than any other.]

What is the result? Well, we see that even with the assumption of maximal uncertainty, while the most likely range expands by a factor of 2.7 (i.e., the range expanded from 3-9 to 1.7-18), it still remains within a manageable range as the extreme edge cases are ruled out, not as impossible but as fairly unlikely.

[Fig. 5: Replacing our original SME distributions that had peaks with uniform distributions flattens out the distribution of our ratio of rentals to sales, causing the 80th percentile prediction interval to widen. The new range runs from about 1.7 to 18.]

The following graph displays the full range of sales and rental variation that is possible depending on our degrees of belief (as represented by our choice of distribution) about the range of total transactions and total value.

[Fig. 6: A scatter plot that demonstrates the distribution of direct sales and rental combinations as conditioned by our choice of distribution type.]

By focusing on the 80th percentile range of outcomes in the ratio of rentals to sales, we can significantly improve the credible range to estimate the rentals and direct sales from the approximate information we were given.

[Fig. 7: A scatter plot that demonstrates the distribution of direct sales and rental combinations as conditioned by our choice of distribution type, constrained only to those values in the 80th percentile prediction interval.]

Precise? Not within a hair’s breadth, no, but the degree of precision we obtain by employing probabilities (as opposed to relying on just a best guess with no understanding of the implications of the range of the assumptions) into our analysis improves by a factor of 13.1 (assuming maximum uncertainty) to 35.2 (trusting our SME). If our own planning depends on an understanding of this sales ratio, we can exercise more prudence in the effective allocation of the resources required to address it. Now, when our manager asks, “How do you know the actual values aren’t near the edge cases?”, we can respond by saying that we don’t know precisely, but using simple algebra combined with probabilities dictates that the actual values most likely are not.

Thursday, February 07, 2013

A Brief Explanation of Expected Value

When helping people analyze the risks they face in complex decisions, I frequently receive requests for an explanation of expected value, as expected value is a measure commonly used to compare the value of alternate risky options. I’ve found that by now most people understand the concept of net present value (NPV) rather well, but they still struggle with the concept of expected value (EV)*. Interestingly enough, and fortunately so, the two concepts share some relationship to each other that makes an explanation a little simpler.

NPV is the means by which we consistently compare cash flows shaped differently in time, assuming that money has a greater meaning to us when we get it or spend it sooner rather than later. For example, NPV would help us understand the relative value of a net cash stream that experienced a small draw down in early periods but paid it back in five years versus a net cash stream that makes a larger draw down in early periods but pays it back in three years.

EV is similar. By it we consistently compare future outcome values that face different probabilities of occurring.

When we do NPV calculations, we don’t anticipate that the final value in our bank account necessarily will equal the NPV calculated. The calculation simply provides a way to make a rational comparison among alternate time-distributed cash streams.

Likewise, when we do EV calculations, we don’t anticipate that the realized value necessarily will equal the EV. In fact, in some cases it would be impossible for that outcome to be the case. EV just simply provides a way to make a rational comparison among alternate probability-distributed outcomes.

Here’s a simple example. Suppose I offer you two gambles to play in order to win some money. (Not really, of course, because the State of Georgia reserves the right to engage in games of chance but prohibits me from doing so.)

In the first game, there are even odds (probability=50%) that you will win either $10 on the outcome of a head or $0 on a tail.

In the second game, which is a little more complicated, I use a biased coin for which the odds are slightly less than even, say, 9:11 (probability=45%), of your winning. If you win, you gain $15; lose, you pay me $5. Which is the better game to play? Believe it or not, the answer depends on how you frame the problem, most notably from your perspective of risk tolerance and how many games you get to play. If you can’t afford to pay $5 if you lose the second game on the first toss, you’re better off to go with the first game because you will lose nothing at least and gain $10 at best. However, if you can afford the possible loss of $5 and you can play the game repeatedly over numerous times, expected value tells us how to compare the two options.

We calculate EV in the following way: EV = prob(H)*(V|H) + prob(T)*(V|T).

For the first game, EV1 = 0.5*($10) + 0.5*(0) = $5.

For the second game, EV2 = 0.45*($15) – 0.55*($5) = $4.

So, since you prefer $5 over $4 (you do, don’t you?), you should play the first game, even though the potential maximum award is alluringly $5 more in game two than one.

But here's the point about the outcomes. At no time in the course of playing either game will you have $5 or $4 in your pocket. Those numbers are simply theoretical values that we use to make a probability-adjusted consistent comparison between two risky options.

In a follow up post, I will describe what your potential winnings could look like if you choose to play either game over many iterations across many parallel universes.

*To be honest, I think part of the persistent problem in understanding is contributed by the term "expected" itself. Colloquially, when people use and hear this term, they think "anticipated." In discussions about risk and uncertainty, the technical meaning really refers to a probability weighted average or mean value. Unfortunately, I don't expect that you should wait for us technical types to accommodate common usage. [back]