{"id":3286,"date":"2023-03-15T16:20:40","date_gmt":"2023-03-15T15:20:40","guid":{"rendered":"https:\/\/www.gironi.it\/blog\/?p=3286"},"modified":"2026-07-16T09:39:22","modified_gmt":"2026-07-16T08:39:22","slug":"first-steps-into-the-world-of-probability-sample-space-events-permutations-and-combinations","status":"publish","type":"post","link":"https:\/\/www.gironi.it\/blog\/en\/first-steps-into-the-world-of-probability-sample-space-events-permutations-and-combinations\/","title":{"rendered":"First Steps into the World of Probability: Sample Space, Events, Permutations, and Combinations"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">How likely is it that a page reaches the first results page? Or that an A\/B test gives a reliable answer? Questions like these \u2014 seemingly very different \u2014 share the same root: to answer them we need <strong>probability<\/strong> and <strong>combinatorics<\/strong>. In this post we lay the foundations, exploring together the basic tools that will accompany us throughout the whole path.<\/p>\n\n\n\n<!--more-->\n\n\n\t\t\t\t<div class=\"wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-dd0eddc7      \"\n\t\t\t\t\tdata-scroll= \"1\"\n\t\t\t\t\tdata-offset= \"30\"\n\t\t\t\t\tstyle=\"\"\n\t\t\t\t>\n\t\t\t\t<div class=\"uagb-toc__wrap\">\n\t\t\t\t\t\t<div class=\"uagb-toc__title\">\n\t\t\t\t\t\t\tWhat we&#8217;ll cover\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"uagb-toc__list-wrap \">\n\t\t\t\t\t\t<ol class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#probability\" class=\"uagb-toc-link__trigger\">Probability<\/a><li class=\"uagb-toc__list\"><a href=\"#the-additivity-principle-for-incompatible-events\" class=\"uagb-toc-link__trigger\">The additivity principle for incompatible events<\/a><li class=\"uagb-toc__list\"><a href=\"#the-multiplication-principle-for-probabilities\" class=\"uagb-toc-link__trigger\">The multiplication principle for probabilities<\/a><li class=\"uagb-toc__list\"><a href=\"#permutation\" class=\"uagb-toc-link__trigger\">Permutation<\/a><ul class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#how-many-different-ways-are-there-to-arrange-4-books-on-a-shelf\" class=\"uagb-toc-link__trigger\">How many different ways are there to arrange 4 books on a shelf?<\/a><li class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#how-many-permutations-are-possible-for-a-set-of-5-letters\" class=\"uagb-toc-link__trigger\">How many permutations are possible for a set of 5 letters?<\/a><\/li><\/ul><li class=\"uagb-toc__list\"><a href=\"#arrangements\" class=\"uagb-toc-link__trigger\">Arrangements<\/a><ul class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#how-many-arrangements-are-possible-from-5-letters-taken-in-groups-of-3\" class=\"uagb-toc-link__trigger\">How many arrangements are possible from 5 letters taken in groups of 3?<\/a><\/li><\/ul><\/li><li class=\"uagb-toc__list\"><a href=\"#the-concept-of-combination\" class=\"uagb-toc-link__trigger\">The concept of Combination<\/a><ul class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#how-many-combinations-are-possible-for-a-set-of-10-people-taken-in-groups-of-3\" class=\"uagb-toc-link__trigger\">How many combinations are possible for a set of 10 people taken in groups of 3?<\/a><li class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#a-class-is-made-up-of-12-boys-and-4-girls-three-of-the-sixteen-students-are-chosen-at-random-what-is-the-probability-that-they-are-all-boys\" class=\"uagb-toc-link__trigger\">A class is made up of 12 boys and 4 girls. Three of the sixteen students are chosen at random: what is the probability that they are all boys?<\/a><\/li><\/ul><\/li><\/ul><li class=\"uagb-toc__list\"><a href=\"#a-concrete-example-choosing-the-keywords-for-a-landing-page\" class=\"uagb-toc-link__trigger\">A concrete example: choosing the keywords for a landing page<\/a><li class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#how-to-choose-the-right-formula\" class=\"uagb-toc-link__trigger\">How to choose the right formula<\/a><\/li><li class=\"uagb-toc__list\"><a href=\"#the-binomial-distribution-as-an-application-of-probability-and-combinatorics\" class=\"uagb-toc-link__trigger\">The binomial distribution as an application of probability and combinatorics<\/a><ul class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#you-might-also-like\" class=\"uagb-toc-link__trigger\">You might also like<\/a><li class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#further-reading\" class=\"uagb-toc-link__trigger\">Further Reading<\/a><\/ul><\/ol>\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\n\n\n<h2 class=\"wp-block-heading\">Probability<\/h2>\n\n\n\n<p class=\"has-light-gray-background-color has-background wp-block-paragraph\">Probability is a mathematical measure that indicates the likelihood of an event occurring. In other words, probability is the ratio between the number of favorable cases and the number of possible cases.<\/p>\n\n\n\n<p class=\"has-text-align-left has-white-background-color has-background wp-block-paragraph\">Probability is based on two fundamental concepts: the <strong>sample space<\/strong> and the <strong>event<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>sample space<\/strong> is the set of all possible outcomes of a random experiment.<br>For example, if we flip a coin, the sample space is {heads, tails}. If we roll two dice, the sample space is {(1,1), (1,2), \u2026, (6,6)}.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">An <strong>event<\/strong> is a subset of the sample space that we are interested in.<br>For instance, if we flip a coin and we care whether it lands heads or tails, the event is {heads} or {tails}. If we roll two dice and want to know whether the sum of the numbers is even or odd, the event is {(2,2), (2,4), \u2026, (6,6)} or {(1,2), (1,4), \u2026, (5,6)}.<\/p>\n\n\n\n<p class=\"has-light-gray-background-color has-background wp-block-paragraph\"><strong>The probability of an event is calculated by dividing the number of favorable cases for the event by the number of possible cases in the sample space.<\/strong><\/p>\n\n\n\n<div class=\"wp-block-uagb-image aligncenter uagb-block-9e81534e wp-block-uagb-image--layout-default wp-block-uagb-image--effect-static wp-block-uagb-image--align-center\"><figure class=\"wp-block-uagb-image__figure\"><img decoding=\"async\" src=\"https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2023\/03\/probabilita.jpg\" alt=\"image of dice to suggest the concept of probability\" class=\"uag-image-2774\" width=\"\" height=\"\" title=\"\" loading=\"lazy\" \/><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">For example:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">if we have a six-sided die and want to know the probability of getting a 4 by rolling it, we have 1 favorable case (the face with the number 4) out of 6 possible cases (the six faces of the die).<br><strong>So the probability of getting a 4 is 1\/6.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Other simple examples:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The probability of getting heads when flipping a coin is 1\/2<\/li>\n\n\n\n<li>The probability that the sum of the numbers is even when rolling two dice is 18\/36 = 1\/2<\/li>\n<\/ul>\n\n\n\n<p class=\"has-light-gray-background-color has-background wp-block-paragraph\"><strong>Probability is expressed as a number between 0 and 1, where 0 indicates the impossibility of the event and 1 indicates its certainty.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A probability value close to 0 indicates a low chance that the event occurs, while a value close to 1 indicates a high chance that it occurs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The additivity principle for incompatible events<\/h2>\n\n\n\n<p class=\"has-light-gray-background-color has-background wp-block-paragraph\">The additivity principle for <strong>incompatible events<\/strong> states that the probability of the union of two or more incompatible events is equal to the sum of their probabilities.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Incompatible events are events that cannot occur at the same time: if one occurs, the other cannot.<br>For example, in rolling a die, the events &#8220;rolling a 3&#8221; and &#8220;rolling a 5&#8221; are incompatible. In this case the probability of the union of the events (that is, rolling a 3 or a 5) equals the sum of their probabilities (1\/6 + 1\/6 = 1\/3).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The multiplication principle for probabilities<\/h2>\n\n\n\n<p class=\"has-light-gray-background-color has-background wp-block-paragraph\">The multiplication principle states that the probability of the intersection of two events equals the product of their individual probabilities, <strong>if the events are independent<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In other words, if A and B are two independent events in a probability experiment, then the probability that both occur at the same time is given by the product of their individual probabilities:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">P(A \u2229 B) = P(A) x P(B).<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<p class=\"wp-block-paragraph\">So far we have computed very simple probabilities: one die, two dice, a coin. But when the number of possible cases becomes large, counting them one by one is impossible. This is where <strong>combinatorics<\/strong> comes in: it lets us determine quickly how many favorable and how many possible cases exist, without having to list them all.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are three fundamental tools in combinatorics: <strong>permutations<\/strong>, <strong>arrangements<\/strong> and <strong>combinations<\/strong>. The difference between them is simple: it depends on how many elements we choose and whether the order matters or not. Let&#8217;s keep this map in mind, then we&#8217;ll look at them one by one.<\/p>\n\n\n\n<div class=\"wp-block-group has-light-gray-background-color has-background\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>How to find your way around combinatorics<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Question<\/th><th>Tool<\/th><\/tr><\/thead><tbody><tr><td>Do I use <strong>all<\/strong> the elements?<\/td><td><strong>Permutations<\/strong> (n!)<\/td><\/tr><tr><td>Do I choose <strong>some<\/strong> and the <strong>order matters<\/strong>?<\/td><td><strong>Arrangements<\/strong> (n!\/(n-r)!)<\/td><\/tr><tr><td>Do I choose <strong>some<\/strong> and the <strong>order does not matter<\/strong>?<\/td><td><strong>Combinations<\/strong> (C(n,k))<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Permutation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Permutations are the ways in which n distinct objects can be ordered in n different positions<\/strong>. For example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The permutations of the letters A, B, C are ABC ACB BAC BCA CAB CBA<\/li>\n\n\n\n<li>The number of permutations of n distinct objects is calculated with the factorial n!, that is the product of the natural numbers from 1 to n<\/li>\n\n\n\n<li>The number of permutations of A, B, C is 3! = 3 x 2 x 1 = 6<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s see a few more examples:<\/p>\n\n\n\n<h6 class=\"wp-block-heading\"><strong>How many different ways are there to arrange 4 books on a shelf?<\/strong><\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">The answer is: n!<br>Recall that &#8220;!&#8221; denotes the factorial, that is the product of all positive integers from 1 to n.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Solution: 4! (4 factorial) = 24 different ways<\/p>\n\n\n\n<h6 class=\"wp-block-heading\"><strong><em>How many permutations are possible for a set of 5 letters?<\/em><\/strong><\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">5! = 5 x 4 x 3 x 2 x 1 = 120<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are 120 possible permutations of 5 letters.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Arrangements<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">So far we have ordered <strong>all<\/strong> the elements. If instead we choose only <strong>some<\/strong> elements from a set and the order matters, we speak of <strong>simple arrangements<\/strong>. The formula is n! \/ (n &#8211; r)!, where n is the total number of elements and r is how many we choose. Arrangements are an intermediate case between permutations and combinations: we do not use all the available elements, only a part of them, while keeping the order meaningful.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\"><strong><em>How many arrangements are possible from 5 letters taken in groups of 3?<\/em><\/strong><\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">n! \/ (n &#8211; r)!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">where &#8220;n&#8221; is the total number of objects (in this case, the 5 letters), and &#8220;r&#8221; is the number of objects we want to choose and arrange in a specific order (in this case, 3 letters).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, substituting the values, we get:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">5! \/ (5 &#8211; 3)! = 5! \/ 2! = (5 x 4 x 3 x 2 x 1) \/ (2 x 1) = 60<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So there are 60 possible arrangements of 5 letters taken in groups of 3. The order matters: ABC is different from ACB, which is different from BAC, and so on.<\/p>\n\n\n\n<p class=\"has-light-gray-background-color has-background wp-block-paragraph\">It is important to note that, when we choose a group of objects from a larger set, <strong>the order in which the objects are chosen matters<\/strong>. If the order matters we are in the case of arrangements; if instead it did not matter, we would use the combinations formula.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The concept of Combination<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Combinations are the ways in which k objects can be chosen from n distinct objects <strong>without considering the order<\/strong>. For example,<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The combinations of two letters from A, B, C are AB AC BC<\/li>\n\n\n\n<li>The number of combinations of k objects from n distinct objects is calculated with the binomial coefficient C(n,k) = n! \/ (k! x (n-k)!)<\/li>\n\n\n\n<li>The number of combinations of two letters from A, B, C is C(3, 2) = 3! \/ (2! x (3-2)!) = 3<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s see a few more examples:<\/p>\n\n\n\n<h6 class=\"wp-block-heading\"><strong><em>How many combinations are possible for a set of 10 people taken in groups of 3?<\/em><\/strong><\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">To calculate the number of combinations possible for a set of 10 people taken in groups of 3, we can use the combinations formula:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">n! \/ (k! * (n &#8211; k)!)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">where &#8220;n&#8221; is the total number of objects (in this case, the 10 people) and &#8220;k&#8221; is the number of objects we want to choose without caring about the order (in this case, 3 people).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, substituting the values, we get:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">10! \/ (3! * (10 &#8211; 3)!) = (10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1) \/ ((3 x 2 x 1) * (7 x 6 x 5 x 4 x 3 x 2 x 1)) = 120<\/p>\n\n\n\n<h6 class=\"wp-block-heading\"><strong><em>A class is made up of 12 boys and 4 girls. Three of the sixteen students are chosen at random: what is the probability that they are all boys?<\/em><\/strong><\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">This example is taken from the Italian State Exam, mathematics topic no. 1 (PNI, school year 2000-2001, standard course, Scientific High School).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The probability of choosing three all-boy students can be computed as the ratio between the number of ways we can choose three boys and the total number of ways we can choose three students out of all sixteen.<br>If we want to choose three all-boy students, we must consider all the possible groups of 3 boys that can be formed by choosing them from the 12 boys.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The number of ways we can choose three boys from the class of 12 boys is given by the combination of 3 elements chosen from the 12 boys. Let&#8217;s compute it with the combinations formula:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">C(12, 3) = 12! \/ (3! * (12-3)!) = 220<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The total number of ways we can choose three students from the class of 16 is given by the combination of 3 elements chosen from the 16 students.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">C(16, 3) = 16! \/ (3! * (16-3)!) = 560<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So the probability of choosing three all-boy students is:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">P(three boys) = C(12, 3) \/ C(16, 3) = 220 \/ 560 = 11 \/ 28<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">A concrete example: choosing the keywords for a landing page<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s now look at an example that perhaps touches more closely the work of those who deal with data analysis and SEO. Suppose we have a list of 15 keywords and we want to choose 3 of them as the focus of a landing page.<\/p>\n\n\n\n<p class=\"has-light-gray-background-color has-background wp-block-paragraph\"><strong>Scenario 1: I only care which keywords to choose<\/strong><br>The order does not matter: the group {technical SEO, content optimization, link building} is the same as {link building, technical SEO, content optimization}.<br>This is a <strong>combination<\/strong>: C(15, 3) = 455 different ways.<\/p>\n\n\n\n<p class=\"has-light-gray-background-color has-background wp-block-paragraph\"><strong>Scenario 2: I also want to set the order in the title<\/strong><br>If the first keyword must go in the title, the second in the H1 and the third in the body, then the order matters. The same group of keywords in a different order produces a different page.<br>This is an <strong>arrangement<\/strong>: 15! \/ (15-3)! = 2730 different ways.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The difference is substantial: 455 possibilities if the order does not matter, 2730 if it does. This is why it is essential to understand first of all <em>whether the order is relevant<\/em> in the problem we are facing.<\/p>\n\n\n\n<p class=\"has-light-gray-background-color has-background wp-block-paragraph\"><strong>A common mistake<\/strong><br>Many students \u2014 and not only students \u2014 confuse permutations and combinations. The simplest criterion to tell them apart is to ask: <em>if I swap the order of the elements, do I get a different result?<\/em><br><br>If yes, the order matters: we are working with permutations or arrangements.<br>If no, the order does not matter: we are in the case of combinations.<br><br>This single question is all we need in order not to go wrong.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How to choose the right formula<\/h3>\n\n\n\n<p class=\"has-light-gray-background-color has-background wp-block-paragraph\"><strong>Do I need to order all the elements?<\/strong> \u2192 <strong>Permutations<\/strong>: n!<br>\n<strong>Do I need to choose some and the order matters?<\/strong> \u2192 <strong>Arrangements<\/strong>: n!\/(n-r)!<br>\n<strong>Do I need to choose some and the order does not matter?<\/strong> \u2192 <strong>Combinations<\/strong>: C(n,k)<br><br>\nWith this scheme, tackling any combinatorial problem becomes much simpler: just identify the type of question and apply the corresponding formula.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The binomial distribution as an application of probability and combinatorics<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In a <strong><a href=\"https:\/\/www.gironi.it\/blog\/en\/probability-distributions-discrete-distributions-and-the-binomial\/\" target=\"_blank\" rel=\"noreferrer noopener\">post specifically dedicated to probability distributions<\/a><\/strong> I examined in detail the properties of the <strong><a href=\"https:\/\/www.gironi.it\/blog\/en\/probability-distributions-discrete-distributions-and-the-binomial\/\" target=\"_blank\" rel=\"noreferrer noopener\">binomial distribution<\/a><\/strong>. I refer you to that post for all the details.<br>Here, though, I would like to introduce it briefly in a direct and practical way, only to answer questions like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>What is the probability that in 10 coin tosses heads comes up 5 times or fewer?<\/li>\n\n\n\n<li>If in 20 multiple-choice questions (each with 4 options) we answer completely at random, what is the probability of answering 15 or more correctly?<\/li>\n\n\n\n<li>In 100 draws with replacement from an urn with 10 white balls and 90 black ones, what is the probability of drawing fewer than 20 white?<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s take the first question. We want to know the probability that in 10 coin tosses heads comes up 5 times or fewer.<br>Proceeding by logic, we should compute the sum of the binomial probabilities for k = 0, 1, 2, 3, 4 and 5. That is:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">P(X &lt;= 5) = P(X = 0) + P(X = 1) + P(X = 2) + P(X = 3) + P(X = 4) + P(X = 5)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Using the binomial probability formula and substituting n = 10 and p = 1\/2, we get:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">P(X &lt;= 5) = C(10 ,0) x (1\/2)^0 x (1\/2)^10 + C(10 ,1) x (1\/2)^1 x (1\/2)^9 + \u2026 + C(10 ,5) x (1\/2)^5 x (1\/2)^5<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Simplifying the calculations and using a calculator, we get:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">P(X &lt;= 5) = &lt;0.001 + &lt;0.01 + &lt;0.04 + &lt;0.12 + &lt;0.21 + &lt;0.25\n\nP(X &lt;= 5) = 0.63<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">So the probability that in 10 coin tosses heads comes up at most five times is about 63%.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Is there a simpler way to reach the correct result?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can introduce the <strong>cumulative distribution function of the binomial distribution<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The cumulative distribution function computes the probability that the random variable X is less than or equal to a certain value k. It is written F(k) and defined as:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">F(k) = P(X &lt;= k) = sum of the binomial probabilities for i = 0, 1, \u2026, k<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This function can be computed with an approximate formula or with a precompiled table. For example, using an online table like this one:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.statisticshowto.com\/tables\/binomial-distribution-table\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.statisticshowto.com\/tables\/binomial-distribution-table\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">where we can find the value of F(5) for n = 10 and p = 1\/2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We just look in the row corresponding to n = 10 and the column corresponding to p = 0.5 and read the value at k = 5. The value is 0.623.<\/p>\n\n\n\n<div class=\"wp-block-group has-background\" style=\"background-color:#f5f7f9;margin-top:2.5rem;margin-bottom:2.5rem;padding-top:1.5rem;padding-right:1.5rem;padding-bottom:1rem;padding-left:1.5rem\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-container-core-group-is-layout-eed7543b wp-block-group-is-layout-constrained\">\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"600\" src=\"https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/probabilita-binomiale-cumulata-en.png\" alt=\"The cumulative probability P(X \u2264 5) for 10 coin tosses is the sum of the six blue bars: 0.623.\" class=\"wp-image-4307\" srcset=\"https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/probabilita-binomiale-cumulata-en.png 975w, https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/probabilita-binomiale-cumulata-en-300x185.png 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><figcaption class=\"wp-element-caption\">The cumulative probability P(X \u2264 5) for 10 coin tosses is the sum of the six blue bars: 0.623.<\/figcaption><\/figure>\n\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Of course, it is much more convenient to use R or Python, especially for larger numbers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s compute it in R with the <code>pbinom<\/code> function, which returns the cumulative probability of a given number of successes in a given number of trials:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Probability of getting 5 or fewer heads in 10 tosses\npbinom(5, size = 10, prob = 0.5)\n# Result: 0.6230469<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The same calculation in Python uses the <code>binom<\/code> class from the <code>scipy.stats<\/code> library:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Import the library\nfrom scipy.stats import binom\n\n# Probability of getting 5 or fewer heads in 10 tosses\nbinom.cdf(5, n = 10, p = 0.5)\n# Result: 0.623046875<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s move on to the second question.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We want to compute the probability of answering 15 or more of 20 multiple-choice questions correctly. If we assume each question has 4 options and only one is correct, then the probability of success is p = 0.25. So we must compute:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">P(X &gt;= 15) = P(X = 15) + P(X = 16) + P(X = 17) + P(X = 18) + P(X = 19) + P(X = 20)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The binomial probability formula is:<\/p>\n\n\n\n\\(\nP(X = x) = {n choose x} p^x (1-p)^{n-x} \\\n\\)\n\n\n\n<p class=\"wp-block-paragraph\">Using the binomial probability formula, we get:<\/p>\n\n\n\n\\(\nP(X geq 15) approx 0.0002\n\\)\n\n\n\n<p class=\"wp-block-paragraph\">So the probability is very, very low\u2026 better to study!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s move on to the third question.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We want to find the probability of drawing fewer than 20 white balls in 100 draws from an urn with 10 white balls and 90 black ones. If we assume the draws are with replacement, then the probability of success (drawing a white ball) is p = 0.1. So we must compute:<\/p>\n\n\n\n$$\nP(X &lt; 20) = P(X leq 19) = sum_{x=0}^{19} {100 choose x} (0.1)^x (0.9)^{100-x}\n$$\n\n\n\nand we get:\n$$\nP(X &lt; 20) approx 0.9988\n$$\n\n\n\n<p class=\"wp-block-paragraph\">So in this case the probability is very high.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These are the basics \u2014 sample space, events, permutations, arrangements, combinations, and a first taste of the binomial. Tools that look simple, yet much of the statistics we use in everyday work rests on them. In the <a href=\"https:\/\/www.gironi.it\/blog\/en\/probability-distributions-discrete-distributions-and-the-binomial\/\">next article on the binomial distribution<\/a> we look more closely at this distribution, seeing how to compute it and when to apply it \u2014 and we will discover it is not nearly as complex as it might seem at first sight.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">You might also like<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.gironi.it\/blog\/en\/bayesian-statistics-how-to-learn-from-data-one-step-at-a-time\/\">Bayesian statistics: how to learn from data, one step at a time<\/a><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">Further Reading<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Two complementary reads to consolidate probabilistic reasoning: <a href=\"https:\/\/www.amazon.it\/dp\/0241258766?tag=consulenzeinf-21&#038;ascsubtag=first-steps-into-the-world-of-probability-sample-space-events-permutations-and-combinations\" rel=\"nofollow sponsored noopener\" target=\"_blank\"><em>The Art of Statistics<\/em><\/a> by David Spiegelhalter for the conceptual framework, and <a href=\"https:\/\/www.amazon.it\/dp\/8867319396?tag=consulenzeinf-21&#038;ascsubtag=first-steps-into-the-world-of-probability-sample-space-events-permutations-and-combinations\" rel=\"nofollow sponsored noopener\" target=\"_blank\"><em>Finalmente ho capito la statistica<\/em><\/a> by Maurizio De Pra (Italian edition) for a gradual, example-rich path.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>How likely is it that a page reaches the first results page? Or that an A\/B test gives a reliable answer? Questions like these \u2014 seemingly very different \u2014 share the same root: to answer them we need probability and combinatorics. In this post we lay the foundations, exploring together the basic tools that will &hellip; <a href=\"https:\/\/www.gironi.it\/blog\/en\/first-steps-into-the-world-of-probability-sample-space-events-permutations-and-combinations\/\" class=\"more-link\">Leggi tutto<span class=\"screen-reader-text\"> &#8220;First Steps into the World of Probability: Sample Space, Events, Permutations, and Combinations&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[161],"tags":[],"class_list":["post-3286","post","type-post","status-publish","format-standard","hentry","category-statistics"],"lang":"en","translations":{"en":3286,"it":2731},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"post-thumbnail":false},"uagb_author_info":{"display_name":"paolo","author_link":"https:\/\/www.gironi.it\/blog\/author\/paolo\/"},"uagb_comment_info":0,"uagb_excerpt":"How likely is it that a page reaches the first results page? Or that an A\/B test gives a reliable answer? Questions like these \u2014 seemingly very different \u2014 share the same root: to answer them we need probability and combinatorics. In this post we lay the foundations, exploring together the basic tools that will&hellip;","_links":{"self":[{"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/posts\/3286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/comments?post=3286"}],"version-history":[{"count":5,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/posts\/3286\/revisions"}],"predecessor-version":[{"id":4308,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/posts\/3286\/revisions\/4308"}],"wp:attachment":[{"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/media?parent=3286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/categories?post=3286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/tags?post=3286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}