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.)
[Note: If you’re not into programming, you can skim past the crunchy geeky bits and still get the flavorful creamy nougat inside. But you have to practice self control to get the delayed satisfaction beneath that layer. You can do it!]
die <- c(4, 6, 8, 10, 12, 15, 18)
n.die <- length(die)
The game master selects a die to be in play but keeps the choice hidden from us. As I’ll explain in more detail later, the game master is the aggregate market or nature, and by “in play,” I mean that some condition that we currently care about in that environment is the case.
die.choice <- 12
Given that we are tasked to infer which die is chosen, and we don’t know any other information other than the number of die in the set (before we observe the outcome of any die toss), any initial guess is as good as the other. Furthermore, we can describe our inclination to believe one situation is the case to the exclusion of any others with a number between 0 and 1, where 0 means that we don’t believe at all, and 1 means that we certainly believe with no reservations. We’ll call this initial guess our prior probability (or our initial degree of belief) that any one of the dice is in play. What number should we assign for each of the possibilities? Well, since we know that any guess is as good as any other, that the possibilities are mutually exclusive, but that any one of the possibiities we’ve identified will certainly be the case, a little thought should tell us that 1/(number of dice)
should be the prior probability that we assign to all the possibilities…at least initially. (Some really smart mathematicians described this as the principle of insufficient reason) As we proceed, we’ll discuss how to update these probabilities as we get more information as we aggregate the outcomes of the toss of the die. In R, we apply this probability across a vector with a size equal to the set of die possibilities.
initial.prob <- 1/n.die
initial.probs <- rep(initial.prob, n.die)
[1] 0.1428571 0.1428571 0.1428571 0.1428571 0.1428571 0.1428571 0.1428571
Before we start the process of observing the die outcomes as they are tossed, create an index to keep track of those trials as they occur. Let’s start with 20 trials.
n.trials <- 20
trials <- 0:n.trials
Initialize the trials outcome vector. The first trial outcome (i.e., trial=0) will be NA because we don’t conduct a trial until trial=1.
trial.outcomes <- rep(0, n.trials+1)
trial.outcomes[1] <- NA
Establish the probability that any face of a given die occurs, assuming that each die is fair. For any die that could be in play, the probability that any of its sides occurs is 1/(number of sides)
. This is another application of the principle of insufficient reason.
outcome.prob <- 1/die
We will keep track of the three key probabilities in three separate arrays as the trials reveal their outcomes. We initialize each array here. The first two arrays are the same size with shape Array(m x n) = (number of trials) x (number of possibilities)
. The third is a vector of length (number of trials)
.
- This array corresponds to the probability typically denoted as prob(evidence | hypothesis) or our “likelihood” function. For our exercise, we interpret this as the probability that we observe a revealed outcome given that the choice of a certain die is in play. The first values at trial=0 are our prior probabilities.
prob.outcome.gv.choice <-
array(rep(0, (n.trials+1) * n.die),
dim = c((n.trials+1), n.die))
prob.outcome.gv.choice[1, ] <- initial.probs
colnames(prob.outcome.gv.choice) <- die
- This array corresponds to the probability typically denoted as prob(hypothesis | evidence) or our posterior probability. For our exercise, we interpret this as the degree of belief that a certain die is in play given the cumulative observations of outcomes.
prob.choice.gv.outcome <- prob.outcome.gv.choice
- This vector corresponds to the sum of probabilities of outcomes on each trial. In each trial, it’s the normalizing constant. The first value at trial=0 is 1 since it is the sum of the initial prior probabilities or (number of possibilities) * (1/(number of possibilities)).
marginal.prob <- sapply(trials, function(t) sum(prob.outcome.gv.choice[t+1, ]))
Before we start our simulated experiment, let’s think a bit more about what each of those three arrays mean. The first array tells us how likely it is that we should observe a given outcome if a die of a certain size is in play. If the die is four-sided, the likelihood that we would observe a 1, 2, 3, or 4 is 1/4; likewise, for a 12-sided die, any one of the faces would have a likelihood of 1/12. The second array keeps track of our degrees of belief that one of the die types was selected for play. The first set of values in this array will be our prior probabilities, which are all equal, but they will change as we observe the outcomes of the tosses. Hopefully, they will do so such that our confidence that one die type is the case moreso than the other possibilities. Finally, the third vector is the sum of the likelihoods for any outcome that occurs. For example, if a 9 appears on a toss, the likelihood that we would observe a 9 for any of the given generating possibilities is…
df.likelihood <- data.frame(die, ifelse(9>=die, 0, outcome.prob))
colnames(df.likelihood) <- c("Die Sides", "Likelihood Given 9")
df.likelihood %>%
kable() %>%
kable_styling(bootstrap_options = "striped",
full_width = F) %>%
column_spec(1, bold = T, border_right = T, width = "2.25cm") %>%
column_spec(2, width = "3.75cm")
Die Sides |
Likelihood Given 9 |
4 |
0.0000000 |
6 |
0.0000000 |
8 |
0.0000000 |
10 |
0.1000000 |
12 |
0.0833333 |
15 |
0.0666667 |
18 |
0.0555556 |
The sum of those values in the right column would be r sum(df.likelihood$Likelihood)
for the trial on which we might observe that 9.
Run the simulation by stepping across the trials index, starting at the second position (i.e., trials=1) by skipping the initial position (i.e., trials=0). The term trials[-1] is a reduced form of the trials index that removes the initial position. As we step through each trial, we will update our posterior probability as
posterior = previous_posterior * observed_outcome_likelihoods / sum(observed_outcome_likelihood)
for (t in trials[-1]) {
# Generate a new outcome for each trial based on the die in play.
trial.outcomes[t+1] <- round(runif(1, 1, die.choice))
# Calculate the new prior probability for each possibility on each new trial.
prob.outcome.gv.choice[t+1, ] <-
(1 - (trial.outcomes[t+1] > die)) *
prob.choice.gv.outcome[t, ] * outcome.prob
# Calculate the marginal probability in each trial.
marginal.prob[t+1] <- sum(prob.outcome.gv.choice[t+1, ])
# Calculate the updated posterior for each possibility on each trial.
prob.choice.gv.outcome[t+1, ] <- prob.outcome.gv.choice[t+1, ] /
marginal.prob[t+1]
}
df.trial.outcomes <- data.frame(trials, trial.outcomes)
colnames(df.trial.outcomes) <- c("trial", "outcome")
df.trial.outcomes %>%
kable(caption = "Table of trials and the associated observed outcome on each.") %>%
kable_styling(bootstrap_options = "striped",
full_width = F) %>%
column_spec(1, bold = T, border_right = T) %>%
column_spec(1:2, width = "3cm")
Table of trials and the associated observed outcome on each.
trial |
outcome |
0 |
NA |
1 |
6 |
2 |
5 |
3 |
5 |
4 |
6 |
5 |
4 |
6 |
4 |
7 |
1 |
8 |
5 |
9 |
9 |
10 |
3 |
11 |
10 |
12 |
10 |
13 |
4 |
14 |
6 |
15 |
5 |
16 |
11 |
17 |
4 |
18 |
4 |
19 |
9 |
20 |
3 |
Now, redefine the prob.choice.gv.outcome array as a data frame for plotting with ggplot2.
df.prob.choice.gv.outcome <- as.data.frame(prob.choice.gv.outcome,
colnames = die)
Transform the data frame df.prob.choice.gv.outcome into a data frame with relational structure such that trial is the left outermost column, die possibility is the next column, and the values are the final right column.
melt.prob.choice.gv.outcome <- melt(cbind(trials, df.prob.choice.gv.outcome),
id.vars="trials")
Plot the probabilities of the die possibilities as they evolve across the trials.
plot.prob.trials <-
ggplot(data = melt.prob.choice.gv.outcome,
aes(x = trials,
y = value,
group = variable,
colour = variable))
plot.prob.trials <- plot.prob.trials + geom_line()
plot.prob.trials <- plot.prob.trials + geom_point()
plot.prob.trials <- plot.prob.trials + theme(axis.text = element_text(size=14),
axis.title = element_text(size=14,face="bold"),
title = element_text(size=16,face="bold"))
plot.prob.trials <- plot.prob.trials + labs(title = "Probability That a Given Die is in Play",
x = "Trials",
y = "Probability"
)
plot(plot.prob.trials)
We can also present this as slices from some selected steps after the first trial across the probabilities of the die possibilities. Determine the rational ordering of each possibility in each slice.
steps <- 5
check.steps <- 1:steps
trial.slices <- c(0, 1, ceiling(check.steps*n.trials/steps))
sub.prob.choice.gv.outcome <- n.die * length(trial.slices)
melt.prob.choice.gv.outcome2 <-
melt.prob.choice.gv.outcome[1:sub.prob.choice.gv.outcome, ]
for (t in 1:length(trial.slices)) {
melt.prob.choice.gv.outcome2[(t-1) * n.die + (1:n.die), ] <-
melt.prob.choice.gv.outcome[melt.prob.choice.gv.outcome$trials==trial.slices[t], ]
}
plot.selection <-
ggplot(data = melt.prob.choice.gv.outcome2, aes(x = variable,
y = value,
fill = variable))
plot.selection <- plot.selection + geom_bar(stat="identity")
plot.selection <- plot.selection + facet_grid(. ~ trials)
plot.selection <- plot.selection + theme(axis.text.x = element_text(size=12),
axis.text.y = element_text(size=14),
axis.title = element_text(size=14,face="bold"),
title = element_text(size=16,face="bold"))
plot.selection <- plot.selection + labs(title = "Die Probability at Selected Trials",
x = "Die Possibilities",
y = "Probability")
plot(plot.selection)
Observations and Conclusions (for as long as they matter)
So, what does all this mean, beside learning some nifty R code? How does it relate to business and our intuition?
Let’s start with our prior probability. In cases in which we can account for the possibilities of outcomes and for which we have no other information than just their designations, we should see that any outcome should be thought of as equally likely. What if we arrange those outcomes from least desirable to most desirable. Instead of overworking our anxiety muscle that the worst case will occur, we can alleviate some of our worry by realizing that the likelihood of better outcomes will most likely be the case. There is an obverse side to this observation, though. Instead of building up our hopes and dreams that the best case will occur, we might temper that enthusiasm a bit by realizing that a less than best case will most likely be the case. From the outset, we should be less inclined to allocate a bulk of our resources on those extreme ends…until we get more information. Regardless, at the beginning, we should be reserved about letting our emotions dominate our minds on the basis of the possibility of extreme outcomes. We should acknowledge they exist, but we shouldn’t purchase worry or exuberance until either are warranted. The world of our future probably lies close to the median.
Now, as we begin to step through the trials (and tribulations of life), we see that our degrees of belief about the type of die that could be in play evolves. In fact, the very first trial obviates the need for hypothesizing that a four sided die could be the case because we observed a 6. Under no circumstances can a four-sided die produce a 6; thus, our degree of belief in 4 collapses to 0. This is an example of disconfirming evidence, a hallmark of the scientific process, the purpose of which is to find reasons not to believe that a postulated belief is true. In this case, we found one. There is no more need to waste time planning on 4-sided die being the cause of the events we observe.
As our evidence accumulates, two possibilities (the 6- or 8-sided die) help us to increase our inclination that either is the case as the other possibilities melt away. This is how experience helps us to learn. As we see more and more examples of evidence for the possibility of a given causal explanation, we increasingly accept the dominate case to be true. But as you see, this only works for a short while. There is a dark side to experience, and it’s called prejudice. In our experiment here, by the end of 8 trials, we would have reached a strong degree of belief that the 6-sided die is the causal mechanism for the events we observe. But then a 9 shows up, and our now possibly cherished belief (the 6-sided die explains my world) is dashed against the rocks. Think about this for a moment. There are many events that don’t occur with a large frequency, and we may be fortunate or unfortunate to observe as many as 8 or 10 of them in our lifetimes. But how many times have we either exhorted or warned others on our “vast experience” that we know the underlying causes for what they may be facing? Let’s admit it here: age confers on us a certain amount of experience, some of which may be simply prejudice.
As our experiment proceeds, we experience again that another explanation for the world increases its dominance, only to be shot down like our last strongly held belief. Will there ever be any relief to this cycle of learning and relearning? Maybe. Maybe not. Notice what happens with the 15-sided die. It’s associated degree of belief declines almost to 0, resurrects again on trial #9, declines almost to 0, and then pulls a third appearance on trial #16, but it never quite makes it back down to 0 even as the associated degree of belief in the 12-sided die approaches 0.99. This is the exact same pattern we observed in the 10- and 12-sided die, leading us to believe that either most likely would not explain our world until that pesky disconfirming evidence showed up to disabuse us of our belief. So, after 20 trials, should we be comfortable believing that the 12-sided die is, in fact, the game piece chosen by the game master? A 0.99 degree of belief, as most of all the other explanations have been disconfirmed, empirically and rationally discarded, is a good reason to bet on that idea.
But don’t get cocky, kid. Although we know in the omniscient setup that the 12-sided die is the one in play, we don’t know that in our simulated world. The 15- and 18-sided die have not yet shown us evidence of their existence. In our simulated world, we might think this could be due to the relatively low probability of any number greater than 12 appearing. And so, another explanation always lurks, awaiting to disconfirm our currently held cherished belief in 12-sided die.
Experience is certainly a good thing. It’s how we learn, but it doesn’t account for everything. Simple simulations like the preceding one can help us understand that and help us think about how we can address that constraint. But it won’t be easy. Life never is. Consider the following two conumdrums.
- We probably won’t be able to account for all the possible explanations for the effects we observe. One of the best ways to address this is to draw on a diversity of experiences and perspectives of others to consider what we alone never might.
- It’s possible that what we see isn’t what we should believe. Eye witness accounts are notoriously unreliable, especially in high stress, high tempo environments. Our measurement devices are sometimes miscalibrated or inherently inaccurate. Suppose, for example, that each time we read the number on the tossed die, there is a intrinsic tendency to misread that outcome, maybe due to fatigue, ailing eyes, or the like. Or suppose we are using a machine that reads a 9 as a 4 every 10th time. Sometimes the possibilities can be mislabeled, either by accident, laziness, or intent. In the case that lack of accuracy is a significant concern, we possibly will never be able to disconfirm any hypothesis altogether.
Back to Incite! Decision Technologies.
LS0tCnRpdGxlOiAnQmF5ZXNpYW4gUmVhc29uaW5nOiBEaXNjcmV0ZSBJbmZlcmVuY2Ugd2l0aCBTZXF1ZW50aWFsIERhdGEnCmF1dGhvcjogIlJvYmVydCBELiBCcm93biBJSUkiCmRhdGU6ICI4LzMvMjAxOCIKb3V0cHV0OgogIGh0bWxfZG9jdW1lbnQ6IGRlZmF1bHQKICBodG1sX25vdGVib29rOiBkZWZhdWx0Ci0tLQoKYGBge3IgbGlicmFyaWVzLCBlY2hvID0gRkFMU0V9CmxpYnJhcnkoZ2dwbG90MikKbGlicmFyeShyZXNoYXBlMikKbGlicmFyeShrbml0cikKbGlicmFyeShrYWJsZUV4dHJhKQpzZXQuc2VlZCg5OCkKYGBgCgpgYGB7ciBzZXR1cCwgaW5jbHVkZT1GQUxTRX0Ka25pdHI6Om9wdHNfY2h1bmskc2V0KGVjaG8gPSBUUlVFKQpgYGAKCkJhY2sgdG8gW0luY2l0ZSEgRGVjaXNpb24gVGVjaG5vbG9naWVzXShodHRwOi8vd3d3LmluY2l0ZWRlY2lzaW9udGVjaC5jb20pLgoKIyMgT3IsIE9uZSBXYXkgSSBMZWFybmVkIHRvIFF1aXQgQmVsaWV2aW5nIE15IFByZWp1ZGljZXMKCkluIG15IFtsYXN0CmFydGljbGVdKGh0dHBzOi8vd3d3LmluY2l0ZWRlY2lzaW9udGVjaC5jb20vdHV0b3JpYWxzL0JheWVzX01hbGVfb3JfRmVtYWxlXzEubmIuaHRtbCkKb24gdGhpcyB0b3BpYywgSSBzaG93ZWQgdGhhdCBjb25zaWRlcmluZyBiYWNrZ3JvdW5kIGluZm9ybWF0aW9uIGNhbiBwbGF5IGEKc2lnbmlmaWNhbnQgcm9sZSBpbiBoZWxwaW5nIHVzIG1ha2UgbGVzcyBiaWFzZWQganVkZ21lbnRzLiBXaGF0IEkgaG9wZSB0byBzaG93Cm5vdyBpcyB0aGF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lKGF4aXMudGV4dCA9IGVsZW1lbnRfdGV4dChzaXplPTE0KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXhpcy50aXRsZSA9IGVsZW1lbnRfdGV4dChzaXplPTE0LGZhY2U9ImJvbGQiKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGUgPSBlbGVtZW50X3RleHQoc2l6ZT0xNixmYWNlPSJib2xkIikpCnBsb3QucHJvYi50cmlhbHMgPC0gcGxvdC5wcm9iLnRyaWFscyArIGxhYnModGl0bGUgPSAiUHJvYmFiaWxpdHkgVGhhdCBhIEdpdmVuIERpZSBpcyBpbiBQbGF5IiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gIlRyaWFscyIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9ICJQcm9iYWJpbGl0eSIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICApCnBsb3QocGxvdC5wcm9iLnRyaWFscykKYGBgCgpXZSBjYW4gYWxzbyBwcmVzZW50IHRoaXMgYXMgc2xpY2VzIGZyb20gc29tZSBzZWxlY3RlZCBzdGVwcyBhZnRlciB0aGUgZmlyc3QKdHJpYWwgYWNyb3NzIHRoZSBwcm9iYWJpbGl0aWVzIG9mIHRoZSBkaWUgcG9zc2liaWxpdGllcy4gRGV0ZXJtaW5lIHRoZSByYXRpb25hbApvcmRlcmluZyBvZiBlYWNoIHBvc3NpYmlsaXR5IGluIGVhY2ggc2xpY2UuCgpgYGB7ciBmaWcud2lkdGg9MTAsIGZpZy5oZWlnaHQ9NH0KCnN0ZXBzIDwtIDUKY2hlY2suc3RlcHMgPC0gMTpzdGVwcwp0cmlhbC5zbGljZXMgPC0gYygwLCAxLCBjZWlsaW5nKGNoZWNrLnN0ZXBzKm4udHJpYWxzL3N0ZXBzKSkKCnN1Yi5wcm9iL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