  {"id":3295,"date":"2022-01-05T08:16:00","date_gmt":"2022-01-05T07:16:00","guid":{"rendered":"https:\/\/www.gironi.it\/blog\/?p=3295"},"modified":"2026-03-01T20:01:14","modified_gmt":"2026-03-01T19:01:14","slug":"the-beta-distribution-explained-simply","status":"publish","type":"post","link":"https:\/\/www.gironi.it\/blog\/en\/the-beta-distribution-explained-simply\/","title":{"rendered":"The Beta Distribution Explained Simply"},"content":{"rendered":"\n<p>The Beta distribution is a crucial probability distribution in <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bayesian_statistics\" target=\"_blank\" rel=\"noreferrer noopener\">Bayesian statistics<\/a>.<\/p>\n\n\n<p>In theoretical probability problems, we know the exact probability value of a single event, making it relatively straightforward to apply basic probability calculation rules to reach the desired result.<\/p>\n\n\n<p><strong>In real life, however, it&#8217;s much more common to deal with collections of observations, and it&#8217;s from this data that we must derive probability estimates<\/strong>.<\/p>\n\n\n<!--more-->\n\n\n<p>To put it more clearly: in life, we almost never have access to the exact probability value of an event: rather, we have data and observations.<br>Deriving probabilities from observed data is what we call <strong>statistical inference<\/strong>.<\/p>\n\n\n<p><strong>Beta is a continuous value distribution<\/strong>, and in this respect, it differs from the <a href=\"https:\/\/www.gironi.it\/blog\/distribuzioni-di-probabilita-distribuzioni-discrete-la-binomiale\/\" data-type=\"post\" data-id=\"807\"><strong>binomial<\/strong><\/a> distribution, which, as we&#8217;ve seen, presents discrete values.<\/p>\n\n\n<p>We define it through a <strong>probability density function<\/strong> (<strong>PDF<\/strong>): (<em>no, not the well-known format created by Adobe&#8230;<\/em>)<\/p>\n\n\n\\(\nBeta(p;\\alpha,\\beta)=\\frac{p^{\\alpha-1} \\times (1-p)^{\\beta-1}}{beta(\\alpha;\\beta)} \\\n\\)\n\n\n<p>where<\/p>\n\n\n<p><em>p<\/em> = is the probability of an event<br>\u03b1 = how many times we observe our event of interest<br>\u03b2 = how many times our event of interest does NOT occur<br>and obviously:<br>\u03b1 + \u03b2 = number of trials<\/p>\n\n\n<p>The beta function (not the \u03b2 value) in the denominator serves to <strong>normalize the result<\/strong> (which will thus be between 0 and 1).<br>It is calculated through numerical integration, since the distribution is continuous.<\/p>\n\n\n<p><strong>The Beta distribution is a probability distribution of probabilities<\/strong>, and since it models a probability, its domain is limited between 0 and 1.<\/p>\n\n\n<div class=\"wp-block-uagb-image alignleft uagb-block-f113a5f9 wp-block-uagb-image--layout-default wp-block-uagb-image--effect-static wp-block-uagb-image--align-left\"><figure class=\"wp-block-uagb-image__figure\"><img decoding=\"async\" src=\"https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2023\/03\/bayes.jpg\" alt=\"Fantasy image of Thomas Bayes working on the beta distribution\" class=\"uag-image-2911\" title=\"\" loading=\"lazy\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Let&#8217;s look at a practical example of the beta distribution using R<\/h2>\n\n\n<p>Imagine that an online game organizer claims that at least 1 in 10 players wins a prize. We have the data, and we know that among the last 800 players, there were 65 winners.<\/p>\n\n\n<p>The question we ask ourselves is: is the game organizer telling the truth based on our data? Can we consider that a player has at least a 10% chance of winning a prize when buying a ticket based on our sample?<\/p>\n\n\n<p>The solution to our question can be easily derived using the beta function with our data:<\/p>\n\n\n<p>We use the cumulative beta distribution:<br>\u03b2 (.1, 65, 735, TRUE)<\/p>\n\n\n<p>In R, it takes just one line to find the part of our function that lies between 0.1 and 1, showing the probabilities above 10% of winning a prize when buying a ticket:<\/p>\n\n\n<pre id=\"rstudio_console_output\" class=\"wp-block-preformatted\">integrate(function(x) dbeta(x,65,735),0.1,1)\n\n0.03170546 with absolute error &lt; 2.3e-06<\/pre>\n\n\n<p>The answer is right before our eyes. The probability of having at least 10% success is just 3.17%. What the game organizer claims, in light of the data, is false.<\/p>\n\n\n<h2 class=\"wp-block-heading\">You might also like<\/h2>\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\n\n<li><a href=\"https:\/\/www.gironi.it\/blog\/en\/confidence-intervals-what-they-are-how-to-calculate-them-and-what-they-do-not-mean\/\">Confidence Intervals: What They Are, How to Calculate Them<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.gironi.it\/blog\/en\/the-normal-distribution\/\">The Normal Distribution<\/a><\/li>\n<\/ul>\n\n\n<h2 class=\"wp-block-heading\">Authoritative online resources to learn more<\/h2>\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/towardsdatascience.com\/beta-distribution-simply-explained-839b3acde6e9\" target=\"_blank\" rel=\"noreferrer noopener\">Beta Distribution, Simply Explained &#8211; Towards Data Science<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.geeksforgeeks.org\/beta-distribution-in-r\/\" target=\"_blank\" rel=\"noreferrer noopener\">Beta Distribution in R &#8211; GeeksforGeeks<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/towardsdatascience.com\/beta-distribution-intuition-examples-and-derivation-cf00f4db57af\" target=\"_blank\" rel=\"noreferrer noopener\">Beta Distribution \u2014 Intuition, Examples, and Derivation &#8211; Towards Data Science<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/statisticsbyjim.com\/probability\/beta-distribution\/\" target=\"_blank\" rel=\"noreferrer noopener\">Beta Distribution: Uses, Parameters &amp; Examples &#8211; Statistics By Jim<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The Beta distribution is a crucial probability distribution in Bayesian statistics. In theoretical probability problems, we know the exact probability value of a single event, making it relatively straightforward to apply basic probability calculation rules to reach the desired result. In real life, however, it&#8217;s much more common to deal with collections of observations, and &hellip; <a href=\"https:\/\/www.gironi.it\/blog\/en\/the-beta-distribution-explained-simply\/\" class=\"more-link\">Leggi tutto<span class=\"screen-reader-text\"> &#8220;The Beta Distribution Explained Simply&#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":[645,161],"tags":[297,296],"class_list":["post-3295","post","type-post","status-publish","format-standard","hentry","category-probability","category-statistics","tag-bayes","tag-beta"],"lang":"en","translations":{"en":3295,"it":2429},"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":10,"uagb_excerpt":"The Beta distribution is a crucial probability distribution in Bayesian statistics. In theoretical probability problems, we know the exact probability value of a single event, making it relatively straightforward to apply basic probability calculation rules to reach the desired result. In real life, however, it&#8217;s much more common to deal with collections of observations, and&hellip;","_links":{"self":[{"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/posts\/3295","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=3295"}],"version-history":[{"count":5,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/posts\/3295\/revisions"}],"predecessor-version":[{"id":3463,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/posts\/3295\/revisions\/3463"}],"wp:attachment":[{"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/media?parent=3295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/categories?post=3295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/tags?post=3295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}