{"id":3480,"date":"2026-03-01T20:47:35","date_gmt":"2026-03-01T19:47:35","guid":{"rendered":"https:\/\/www.gironi.it\/blog\/the-geometric-distribution\/"},"modified":"2026-03-02T09:30:58","modified_gmt":"2026-03-02T08:30:58","slug":"the-geometric-distribution","status":"publish","type":"post","link":"https:\/\/www.gironi.it\/blog\/en\/the-geometric-distribution\/","title":{"rendered":"The Geometric Distribution"},"content":{"rendered":"<p>After looking at the most famous discrete distribution, the <a href=\"https:\/\/www.gironi.it\/blog\/en\/probability-distributions-discrete-distributions-and-the-binomial\/\" target=\"_blank\" rel=\"noreferrer noopener\">Binomial<\/a>, as well as the <a href=\"https:\/\/www.gironi.it\/blog\/la-distribuzione-di-poisson\/\" target=\"_blank\" rel=\"noreferrer noopener\">Poisson distribution<\/a> and the <a href=\"https:\/\/www.gironi.it\/blog\/en\/the-beta-distribution-explained-simply\/\" target=\"_blank\" rel=\"noreferrer noopener\">Beta distribution<\/a>, it is time to take a look at the <em><strong>geometric distribution<\/strong><\/em>.<\/p>\n<p><!--more--><\/p>\n<div style=\"border: 1px solid #ccc;padding: 1.2em 1.5em;margin: 1.5em 0;border-radius: 6px\">\n<h3 style=\"margin-top: 0\">What We&#8217;ll Cover<\/h3>\n<ul>\n<li><a href=\"#how-many-trials\">How Many Trials Until the First Success?<\/a><\/li>\n<li><a href=\"#examples\">Worked Examples<\/a><\/li>\n<li><a href=\"#r-code\">Computing in R<\/a><\/li>\n<li><a href=\"#further-reading\">Further Reading<\/a><\/li>\n<\/ul>\n<\/div>\n<h2 id=\"how-many-trials\"><strong>How Many Trials Until the First Success?<\/strong><\/h2>\n<p>We use the geometric distribution when we perform independent trials, each of which can result in either success or failure, and <strong>we want to know how many trials are needed to obtain the first success<\/strong>.<\/p>\n<p>In symbols:<\/p>\n\\( X \\sim Geo(p) \\\\ \\\\ \\)\n<ul>\n<li>\\(X\\) is the number of trials needed to obtain the first success.<\/li>\n<li>\\(r\\) is the number of trials.<\/li>\n<li>\\(P\\) is the probability of success on each trial.<\/li>\n<li>We also define, as is natural: q = 1 &#8211; p<\/li>\n<\/ul>\n<p>Here is where it gets interesting. We have:<\/p>\n\\( \\\\ P(X=r) = p \\times q ^ {r-1} \\\\ \\)\n<p><strong>P therefore denotes the probability that the first success occurs on trial number r.<\/strong><br \/>Let us continue our reasoning:<\/p>\n\\( P(X > r) = q ^ {r} \\)\n<p><strong>This allows us to calculate the probability that more than r trials are needed before the first success<\/strong>, as well as:<\/p>\n\\( P(X \\leq r) = 1 &#8211; q ^ {r} \\\\ \\)\n<p>which helps us find the probability that r trials or fewer are needed to achieve the first success. The expected value is:<\/p>\n\\( E(X) = \\frac{1}{P} \\\\ \\)\n<p>The <strong>variance<\/strong> is:<\/p>\n\\( Var(X) = \\frac{q}{P^{2}} \\)\n<h2 id=\"examples\">Worked Examples<\/h2>\n<p>We know that the probability of an ice skater completing a course without incident is 0.4. Therefore:<\/p>\n\\( X \\sim Geo(0.4) \\\\ \\)\n<p>X is the number of attempts our skater must make in order to complete a course without any incident.<\/p>\n<p>We are now ready to apply our new knowledge.<\/p>\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2023\/04\/Firefly_anice-skater-glides-on-the-rink-ring.-The-ice-is-covered-in-numbers-representing-probabilities._art_42785-1024x745.jpg\" alt=\"Artistic representation of the ice skater example for the geometric distribution\" loading=\"lazy\" \/><\/figure>\n<p>Let us calculate the expected number of attempts before achieving a success:<\/p>\n<p>\\( E(X) = \\frac{1}{P} \\\\ \\)<br \/>\ntherefore<br \/>\n\\( \\frac{1}{0.4} = 2.5 \\)<\/p>\n<p>The variance in the number of attempts is quickly calculated:<\/p>\n<p>\\( Var(X) = \\frac{q}{p^{2}} \\\\ \\)<br \/>\nthat is<br \/>\n\\( \\frac{0.6}{0.4^{2}} = \\frac{0.6}{0.16} = 3.75 \\\\ \\)<\/p>\n<p>The probability of succeeding on the second attempt, after having failed the first:<\/p>\n<p>\\( P(X=2) = P \\times q = 0.4 \\times 0.6 = 0.24 \\\\ \\)<br \/>\nthat is, 24%<\/p>\n<p>The probability of succeeding in 4 attempts or fewer? Easy!<\/p>\n\\( P(X \\leq 4) = 1-q^{4} = 1 &#8211; 0.6^{4} = 1 &#8211; 0.1296 \\\\ \\)\n<p>That is 0.8704, or 87%.<\/p>\n<p>The probability of needing more than 4 attempts? A simple calculation:<\/p>\n\\( P(X > 4) = q^{4} = 0.6^{4} \\\\ \\)\n<p>That is 0.1296, or about 13%.<\/p>\n<hr \/>\n<h2 id=\"r-code\">Computing in R<\/h2>\n<p>Now that we have the formulas well in mind, we can let our laziness take over and use R to do the heavy lifting.<\/p>\n<p>With P(X=2) and P=0.4:<\/p>\n<pre><code class=\"language-r\">dgeom(1, 0.4)<\/code><\/pre>\n<p>where 1 is the number of failures before the first success.<\/p>\n<p>P(X&lt;=4) and P=0.4:<\/p>\n<pre><code class=\"language-r\">pgeom(3, 0.4)<\/code><\/pre>\n<p>Simple, quick, and fun!<\/p>\n<hr \/>\n<h3>You might also like<\/h3>\n<ul>\n<li><a href=\"https:\/\/www.gironi.it\/blog\/en\/probability-distributions-discrete-distributions-and-the-binomial\/\">Probability Distributions: Discrete Distributions and the Binomial<\/a><\/li>\n<li><a href=\"https:\/\/www.gironi.it\/blog\/en\/the-negative-binomial-distribution\/\">The Negative Binomial Distribution<\/a><\/li>\n<li><a href=\"https:\/\/www.gironi.it\/blog\/en\/the-normal-distribution\/\">The Normal Distribution<\/a><\/li>\n<\/ul>\n<hr \/>\n<h3 id=\"further-reading\">Further Reading<\/h3>\n<p>For an accessible yet thorough introduction to discrete probability distributions\u2014including the geometric\u2014<a href=\"https:\/\/www.amazon.it\/dp\/8867319396?tag=consulenzeinf-21\" rel=\"nofollow sponsored noopener\" target=\"_blank\"><em>Finalmente ho capito la statistica<\/em><\/a> by Maurizio De Pra covers these topics in a clear and approachable style, ideal for building solid intuition.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After looking at the most famous discrete distribution, the Binomial, as well as the Poisson distribution and the Beta distribution, it is time to take a look at the geometric distribution.<\/p>\n","protected":false},"author":2,"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-3480","post","type-post","status-publish","format-standard","hentry","category-statistics"],"lang":"en","translations":{"en":3480,"it":863},"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":"autore-articoli","author_link":"https:\/\/www.gironi.it\/blog\/author\/autore-articoli\/"},"uagb_comment_info":0,"uagb_excerpt":"After looking at the most famous discrete distribution, the Binomial, as well as the Poisson distribution and the Beta distribution, it is time to take a look at the geometric distribution.","_links":{"self":[{"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/posts\/3480","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\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/comments?post=3480"}],"version-history":[{"count":1,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/posts\/3480\/revisions"}],"predecessor-version":[{"id":3487,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/posts\/3480\/revisions\/3487"}],"wp:attachment":[{"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/media?parent=3480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/categories?post=3480"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/tags?post=3480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}