« All Episodes

Decision-making Skills: Two Types of Probabilistic Thinking

Published 6/21/2021

When you think about probabilities, you likely think in one of two ways. We'll talk about both of these models for probabilistic analysis, their drawbacks, and decision-making in the face of uncertainty.

✨ Sponsor: Square

Payment acceptance can be one of the most painful parts of building a web app for a business. When implementing checkout, you want it to be simple to build, secure, and slick to use. Square’s new Web Payment SDK raises the bar in payment acceptance developer experience and provides a best-in-class interface for merchants and buyers.

Learn more about integrating with Square’s Web Payments SDK at http://squ.re/developertea

📮 Ask a Question 

If you enjoyed this episode and would like me to discuss a question that you have on the show, drop it over at: developertea.com. 

📮 Join the Discord

If you want to be a part of a supportive community of engineers (non-engineers welcome!) working to improve their lives and careers, join us on the Developer Tea Discord community by visiting https://developertea.com/discord today!

🧡 Leave a Review

If you're enjoying the show and want to support the content head over to iTunes and leave a review! It helps other developers discover the show and keep us focused on what matters to you.

Transcript (Generated by OpenAI Whisper)
Decision making is one of the most critical skills that you'll use, basically your whole life. If I had to sum up what I hope for the listeners of this show, it is to learn how to make better decisions. Yes, of course, finding clarity, perspective, and purpose is the goal of Developer Tea, but the point of finding those things is ultimately to be able to use them to make tangible differences in your life through decision making. The vast majority of what you will experience in your life for the most part, for most people listening to this show, there are certainly exceptions, but for most people listening to the show, the majority of what you experience will be at least influenced heavily by your decisions. Now, I do want to make it clear that not everybody would experience the same things given the same decisions. There are problems that we have to face at a higher level as a society, as a culture, but your decisions make a huge difference in your life. Given two paths, you can have wildly different outcomes based on your decisions. So because of the importance of decision making, it makes sense for us to spend basically all of our time on this show talking about different ways to make better decisions. And one of the most important things to understand about decision making is that decision making is about guessing. Decision making is about predicting. That's about imagining a future after the decision is made, unless you are making decisions based on pure chaos. If you're trying to incite a chaotic response, or perhaps even if you are trying to incite a chaotic response, you're still having to predict that your decision in that moment will actually incite that response. So all decision making really is about trying to predict what will happen in the future. And the most reasonable ways to predict what will happen in the future, this is covered by a lot of the things that we talked about in the past on this show. But I want to talk about a specific set of two ways of thinking about prediction. And specifically when we say prediction in this case, we're talking about running some kind of predictive probability. All right? So there's two different branches of probabilistic thinking that I want to talk about on today's show. And again, the whole point of this is to try to refine our decision making. To be clear, nobody can actually predict the future. But some guesses are better than others. If you had perfect clarity on what would happen in the future, then decision making wouldn't even really be a problem. You would know exactly what decisions to make in order to get certain things to happen in order to change some future state. If you could see all of those possible outcomes, then you would make whatever decision you want to make to affect whatever change you want to affect. So because we can't, because we can't see the future, we can't predict the future perfectly, we have to use some kind of way, some method to determine our future. And this is one thing that sets humans apart from other animals, other species. There are some species that can run a few kind of probability that they can be trained into believing or understanding that if they do a particular action, then a particular response will occur, but not any other species can understand multivariate possibilities. The decision tree, this is a uniquely human thing that we can imagine a different reality, our imagination sets us apart. And this is a part of how we are able to survive. This is a critical for us to understand where this comes from, right? We're able to survive because we can predict with some level of slightly better accuracy than another version of us that couldn't predict. We can predict a bad outcome and avoid it or we can predict a good outcome and seek it. Again, not perfectly, but better than someone who doesn't have a species that doesn't have imagination. Okay. So let's talk about these two different kinds of probability. We're going to talk about them through the lens of fatherhood. For many people who are listening to this podcast right now, Father's Day was yesterday. And when my wife and I were expecting both of our children, people would often ask us, do you think your child will be a male or a female? Do you think you're going to have a boy or a girl? I want to give you some time to think about this question and imagine how you would answer the question yourself given the knowledge that you have and try to answer it however you would. While you're doing that, we're going to take a quick break and talk about today's sponsor Square. Having built a lot of web apps myself, one of the most painful parts building a web app is taking payments. When you're implementing a checkout, you want it to be simple to build and maintain. You want it to be secure and slick to use. Square's new web payment SDK raises the bar in payment acceptance developer experience and provides a best in class interface for merchants and ultimately for customers. You can build a customized branded payment experience with the web payments SDK and never miss a sale. They'll deliver a highly responsive payments flow across web and mobile that integrates with credit and debit cards, digital wallets like Apple Pay and Google Pay, ACHBing payments and even gift cards. For more complex transactions, follow-up actions by the customer can include completing a payment authentication step, filling a credit line application form or doing background risk checks on the buyer device. Developers don't even need to know if a payment method requires verification and if so what type. Your hides all of that complexity from the seller and guides buyers through the necessary steps. You can get started with the new web payments SDK easily. Simply include the web payments SDK JavaScript, flag an element on the page where you want the payment form to appear and then attach hooks for your custom behavior. Learn more about integrating with Square's web payments SDK at squ.re slash Developer Tea. That's squ.re slash Developer Tea. A huge thank you to squ.re for their support of Developer Tea. Of course it can be exciting to try to answer this question, to try to influence the outcome when you were expecting a child. My wife and I certainly did a lot of research before we had any kind of confirmation. There's all kinds of information out there if your baby's heartbeat is some particular range than it might be a boy or it might be a girl. And all of this information we use to try to understand what are we getting ready to find out the sex of this baby is. But I want to back up and talk about this from a very calculated and cold perspective, the statistical perspective or probabilistic perspective. Really there are two schools of thought. The first is thinking in a vacuum of sorts, looking purely at the data that you have available about the specific event that you're trying to predict. This idea is very simple. We look at enough iterations of a given question, enough occurrences of that specific event, and we look at the outcomes of those occurrences and we use that to inform what we guess about the future. If let's say we had already had three children and all of those children were female, then we might use this approach to predict that we're going to have a fourth female. Another version of this, very similar to this, let's imagine that we hadn't had any children, we might use the same concept to inform us by broadening that to say that all humans are included in this particular question. We'll use the probability of having a boy versus a girl that is common to us, that's common to humans. The critical factor here is that we're looking at some number of samples. We're using some previously collected information and we're basing our probabilities off of the probabilities found in that collection of information in the data that we already have. And importantly, in this case, in the data about the same event, the same kind of measurement that we're looking at. In statistics, this is called a frequentist approach. In other words, how frequently does outcome a occur versus outcome b? It turns out that on a global scale, humans tend to have slightly more boys than girls. So if you were to have no other information available and if you were taking the frequentist approach specifically, then your most rational answer is that it's likely to be a boy. However, if you were to take in more information, for example, a quick, good girl, you would go to Google search, let me do this article that says that men are more likely to father female offspring during high level soccer training. And I'm sure there's about a thousand or maybe a million more articles like this one that you may use to try to predict what sex your baby is going to be. So we can imagine that if I as the father was an intense soccer player, then there's some percentage more likelihood that I could have a female offspring rather than a male offspring. All right. So if we were to take in, let's say three or four or five of these different studies, we may be able to predict differently what the baby's sex is going to be even in the absence. And here's the critical thing, even in the absence of the original data. This is called Bayesian statistics. And without getting into the math of this difference between these two, really what we're talking about is in one case, in the frequent statistics approach, you have only the information about the event that you're measuring. And then in the Bayesian statistics approach, they're taking in all relevant information that you can. So we're going to set aside the kind of fatherhood story here. And instead we're going to look at other stories that might be relevant to our jobs as software engineers or other kind of predictions. For example, will this language catch on? Will this language catch on? Well, if we look at all of the languages that have caught on versus all the ones that haven't, we might have trouble finding the information about that. But maybe we can use some other information to predict this, right? We can use theory rather than observation. This is the critical point that I want you to take away. Theory and observation both, right? Both approaches are trying to get to the same answer. Both approaches are trying to get to the same answer. If you were to use perfect theory, right? If you were to not have any kind of bias, and we'll talk about that in a moment, in any of your measures on the Bayesian side, and all of your modifiers and all of the prior knowledge that you have is accurate and you have all the right inputs. And then if you were to have a clean set of data that perfectly represents the cases that your Bayesian information represents, then both of those should reflect the same information because both of these are trying to guess the truth, both of these approaches are trying to get to the same thing. But here's the critical point that we need to understand, right? Because we're trying to get to the same thing, we have two different approaches. Why do these two different approaches exist? Sometimes one approach is better than the other. Based on the information that you have available, for example, maybe you don't have a large number of data points to glean your information from, right? Or maybe you don't have a lot of domain specific knowledge to use in your prior understanding. There are times when both of these approaches are necessary. And when your real data is showing a divergence, in other words, when one approach is working and another approach is not working, one approach is guessing properly and the other approach is not guessing properly, then one of two things is happening. Either there's an anomaly, there's an anomaly in the data, right? Or an anomaly that your frequentist approach is picking up on, but that your Bayesian approach can't pick up on. Or your Bayesian approach has some kind of distortion in it. Your ability to predict based on theory is using the wrong theory. And why is this critical? Why is it important to understand what happens when these two things diverge and the fact that they're trying to get to the same place? This is critical because we need to understand how to refine these systems. These statistically driven ways of thinking about future events, if we have a broken set of priors, right, a broken set of prior information that we're using to make decisions, we should be able to inspect that. If we are experiencing an anomaly that our frequentist approach is able to kind of change along with because we're just measuring the data that we have that diverges, right? It diverges away from our theory. Then we should probably investigate why is this diverging? Perhaps we need to update our theory to understand the anomalies better. No matter what approach you take to decision making and more specifically predicting the outcomes of those decisions, keep in mind that there is no perfect system and that you make decisions based on the information you have available. If you make a decision based on certain information, then you've made the right decision despite the outcome. We can't control the future with our decisions. We can only influence it. Thanks so much for listening to today's episode of Developer Tea. Thank you again to today's sponsor Square. It started with the web payments SDK JavaScript by heading over to squ.re slash Developer Tea right now. Thanks so much for listening to this episode. If you enjoyed this discussion on Developer Tea, then you'll probably enjoy our community as well. Head over to developer.com slash discord to join the discord community. That's developertea.com slash discord. This show can only thrive and continue to exist because of you, the listener. So first, thank you. Thank you for listening to this show. Week in and week out, we've done approaching a thousand episodes. We should hit a thousand episodes this year, which is mind boggling to me. But we also can only thrive if you continue to listen and leave ratings and reviews for this show. This helps other engineers like you find and subscribe to Developer Tea. So if you haven't subscribed, go ahead and do that. And then the biggest way that you can help the show out, since we do this purely based on sponsor support, is to go and leave a rating and review in whatever platform that you use that supports ratings and reviews. The biggest one, of course, is iTunes. And there are others as well. Thank you so much for supporting the show. And until next time, enjoy your tea.