{"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-07-12T20:16:11","modified_gmt":"2026-07-12T19:16:11","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 class=\"wp-block-paragraph\">Imagine we have 800 sessions on a landing page and 65 conversions. The raw rate is 65\/800 \u2248 8.1%. It looks like a precise number, but is it really? Is it the <em>true<\/em> conversion probability of the page, or could it be different? And if someone claimed the page converts at least 10% \u2014 do the data confirm or contradict that?<br> Questions like this are everyday fare for anyone working with traffic and conversion data. Bayesian statistics offers an elegant and direct tool to answer them: the <strong>Beta distribution<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Beta distribution is a <strong>continuous probability distribution<\/strong> defined on the interval [0, 1]. That sounds abstract, but it&#8217;s exactly what we need whenever we want to model the uncertainty around a <strong>proportion<\/strong>: a conversion rate, a CTR, a click percentage, a probability of success. Intuitively, Beta is a distribution over the possible probabilities of the event, and that is what makes it unique.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What we&#8217;ll cover<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"#what-is-a-distribution-over-probabilities\">What is a distribution over probabilities<\/a><\/li><li><a href=\"#parameters-alpha-beta-flexibility\">Parameters \u03b1 and \u03b2: the flexibility of the Beta<\/a><\/li><li><a href=\"#shape-tells-the-story\">Shape tells the story<\/a><\/li><li><a href=\"#example-online-game\">An example: the online game<\/a><\/li><li><a href=\"#seo-example-estimating-conversion-rate\">An SEO example: estimating a conversion rate<\/a><\/li><li><a href=\"#beta-sequential-updating\">The Beta as sequential updating<\/a><\/li><li><a href=\"#try-it-yourself\">Try it yourself<\/a><\/li><li><a href=\"#further-reading\">Further reading<\/a><\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-a-distribution-over-probabilities\">What is a distribution over probabilities<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In real life, unlike textbook probability problems, we almost never have the exact value of a probability \u2014 we have data.<br> We have 65 conversions out of 800 visits, not the &#8220;true&#8221; conversion rate of the page. Our job is to work back from those data to an estimate of the hidden value and, above all, to an idea of <em>how uncertain<\/em> that estimate is.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A probability distribution like the Beta solves precisely this problem: instead of a single number (the raw 8.1%), we get a <strong>curve that assigns a degree of plausibility to every possible value of the proportion<\/strong>. Higher points on the curve correspond to more probable values; lower points to less probable ones. Uncertainty is not a flaw in the estimate \u2014 it is part of the result.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In technical terms, the Beta is defined by its <strong>probability density function<\/strong> (PDF):<\/p>\n\n\n\n\\( Beta(p; \\alpha, \\beta) = \\frac{p^{\\alpha-1} \\times (1-p)^{\\beta-1}}{B(\\alpha, \\beta)} \\\\ \\)\n\n\n\n<p class=\"wp-block-paragraph\">Where:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>\\(p\\)<\/strong> \u2014 the proportion we are estimating (a value between 0 and 1)<\/li><li><strong>\\(\\alpha\\)<\/strong> and <strong>\\(\\beta\\)<\/strong> \u2014 the shape parameters, which determine the appearance of the distribution<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Later we will see that \u03b1 and \u03b2 can be interpreted as counts of successes and failures, starting from an initial value chosen as the prior. For now, let&#8217;s focus on their influence on the shape.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The function <strong>\\(B(\\alpha, \\beta)\\)<\/strong> in the denominator serves solely to normalize the distribution, ensuring the total area under the curve equals 1 \u2014 as required for any probability distribution.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"parameters-alpha-beta-flexibility\">Parameters \u03b1 and \u03b2: the flexibility of the Beta<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The real strength of the Beta is its <strong>flexibility<\/strong>. Depending on \u03b1 and \u03b2 values, its shape changes dramatically, making it suitable for very different scenarios:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>When \u03b1 and \u03b2 are equal, the distribution is <strong>symmetric<\/strong> around 0.5<\/li><li>When \u03b1 &gt; \u03b2, the distribution is <strong>skewed to the right<\/strong> (higher values more likely)<\/li><li>When \u03b1 &lt; \u03b2, the distribution is <strong>skewed to the left<\/strong> (lower values more likely)<\/li><li>When \u03b1 = \u03b2 = 1, the Beta becomes a <strong>uniform<\/strong> distribution \u2014 all values between 0 and 1 are equally likely (non-informative prior)<\/li><li>When \u03b1 and \u03b2 are both less than 1, the distribution takes a <strong>U-shape<\/strong> (high probability at the extremes, low in the middle)<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The mean of the Beta is calculated with a simple formula:<\/p>\n\n\n\n\\( \\text{Mean} = \\frac{\\alpha}{\\alpha + \\beta} \\\\ \\)\n\n\n\n<p class=\"wp-block-paragraph\">And the mode (for \u03b1 &gt; 1 and \u03b2 &gt; 1):<\/p>\n\n\n\n\\( \\text{Mode} = \\frac{\\alpha &#8211; 1}{\\alpha + \\beta &#8211; 2} \\\\ \\)\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"shape-tells-the-story\">Shape tells the story<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s look at four parameter combinations to see visually how versatile the Beta is:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-4101\" src=\"..\/figure\/out\/beta-forme-en.pdf\" alt=\"Beta distribution with four different parameter combinations: Beta(0.5, 0.5) U-shaped, Beta(2, 5) skewed left, Beta(5, 2) skewed right, Beta(5, 5) symmetric bell-shaped.\"\/><figcaption class=\"wp-element-caption\">Beta distribution with four different parameter combinations: Beta(0.5, 0.5) U-shaped, Beta(2, 5) skewed left, Beta(5, 2) skewed right, Beta(5, 5) symmetric bell-shaped.<\/figcaption><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Beta(0.5, 0.5)<\/strong> \u2014 U-shaped: high probability at the extremes (near 0% and 100%), low in the middle. A prior used when we suspect the phenomenon is &#8220;all or nothing&#8221;.<\/li><li><strong>Beta(2, 5)<\/strong> \u2014 skewed right (long tail toward 1): useful when the proportion tends to be low.<\/li><li><strong>Beta(5, 2)<\/strong> \u2014 skewed left: for proportions that tend to be high.<\/li><li><strong>Beta(5, 5)<\/strong> \u2014 symmetric bell centered on 0.5: when the evidence is balanced.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The same mathematical family produces such different shapes: this is why the Beta is the most widely used distribution for modeling proportions and probabilities in Bayesian statistics.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"example-online-game\">An example: the online game<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s jump into an example. An online game organizer claims that at least 1 in 10 players wins a prize. We have the data from the last 800 players, among whom there were 65 winners.<br> Is the organizer telling the truth? Based on the data, do we think the probability of winning is at least 10%?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We use the Beta. Our <strong>prior<\/strong> \u2014 what we know before seeing the data \u2014 is Beta(1, 1), the uniform distribution that assigns equal plausibility to every possible value. After observing 65 winners out of 800, the <strong>posterior<\/strong> is Beta(66, 736). Why 66 and 736? Because with a Beta(1, 1) prior, the posterior parameters are \u03b1 = 1 + successes and \u03b2 = 1 + failures, so \u03b1 = 1 + 65 = 66 and \u03b2 = 1 + 735 = 736.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s calculate the probability that the true win rate is at least 10%:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Non-informative prior: Beta(1,1)\n# Data: 65 winners out of 800 players\n# Posterior: Beta(1 + 65, 1 + 735) = Beta(66, 736)\na_post &lt;- 66; b_post &lt;- 736\n\n# Probability that p &gt;= 0.10 \u2014 two equivalent ways\nintegrate(function(x) dbeta(x, a_post, b_post), 0.10, 1)\n1 - pbeta(0.10, a_post, b_post)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>0.03974288 with absolute error &lt; 2.3e-06\n0.03974288<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Based on the data, the probability that the true win rate is at least 10% is about 4%.<\/strong> The organizer&#8217;s claim appears implausible.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-4102\" src=\"..\/figure\/out\/beta-esempio-en.pdf\" alt=\"Posterior Beta(66, 736) with non-informative prior Beta(1,1). The red area corresponds to P(p \u2265 10%) \u2248 4% \u2014 the region where the organizer's claim would be true.\"\/><figcaption class=\"wp-element-caption\">Posterior Beta(66, 736) with non-informative prior Beta(1,1). The red area corresponds to P(p \u2265 10%) \u2248 4% \u2014 the region where the organizer&#8217;s claim would be true.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The figure shows the flat prior (orange horizontal line) and the posterior Beta(66, 736) (blue curve). The shaded red area to the right of the 10% threshold is tiny \u2014 about 4% \u2014 while the vast majority of the distribution lies below 10%.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can also read the credible interval of the distribution \u2014 the Bayesian equivalent of a confidence interval, but with a more direct meaning:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Mean and 95% CI of the posterior\ncat(\"Mean:\", round(66\/(66+736), 3), \"\\n\")\ncat(\"95% CI:\", round(qbeta(c(0.025, 0.975), 66, 736), 3))<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Mean: 0.082\n95% CI: 0.064 0.102<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-4103\" src=\"..\/figure\/out\/beta-posterior-ci-en.pdf\" alt=\"Posterior Beta(66, 736) with mean (green), mode (orange) and 95% credible interval (red segment): the distribution is concentrated between 6.4% and 10.2%.\"\/><figcaption class=\"wp-element-caption\">Posterior Beta(66, 736) with mean (green), mode (orange) and 95% credible interval (red segment): the distribution is concentrated between 6.4% and 10.2%.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The most probable win rate is around 8.2%, with a 95% credible interval between 6.4% and 10.2%. The organizer claimed 10% \u2014 right at the upper bound of our estimate, with less than 3% probability that the true value is higher. Not impossible, but decidedly implausible.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"seo-example-estimating-conversion-rate\">An SEO example: estimating a conversion rate<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s return to the opening case: 65 conversions out of 800 sessions on a landing page. We estimate the conversion rate with the Beta, exactly as we just did.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With a non-informative prior Beta(1, 1) and the observed data, the posterior is Beta(66, 736). The mean is 66\/802 \u2248 8.2%, with a 95% CI between 6.4% and 10.2%.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>This interval is the statistical answer to the question &#8220;how much can I trust my conversion rate?&#8221;<\/strong> The raw 8.1% we see in GA4 is just the center of the distribution: the true value could reasonably lie anywhere between 6.4% and 10.2%.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If we accumulate more data \u2014 say 200 conversions out of 2200 total sessions \u2014 with a Beta(1, 1) prior, the posterior becomes Beta(201, 2001), the mean is 201\/2202 \u2248 9.1% but the 95% CI narrows to [8.0%; 10.4%]: uncertainty decreases because we have more evidence.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If instead we have very little data (5 conversions out of 50 sessions), the posterior Beta(6, 46) gives a mean of 6\/52 \u2248 11.5% and a 95% CI of [4.9%; 20.6%] \u2014 enormous uncertainty. Here the Beta does not hide the uncertainty: it displays it honestly.<\/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:1.5rem;padding-left:1.5rem\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p>A word of caution: the Beta models our <em>uncertainty about<\/em> the proportion, not the proportion itself. The result is not &#8220;the conversion rate is 8.2%&#8221;, but &#8220;based on the data, the distribution of our uncertainty about the rate is Beta(66, 736)&#8221;. It is a subtle but fundamental difference \u2014 and it is the heart of the Bayesian approach.<\/p>\n<\/div><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"beta-sequential-updating\">The Beta as sequential updating<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">One of the most elegant properties of the Beta is that it supports <strong>sequential updating<\/strong>: if after the first 65 conversions out of 800 sessions we observe another 40 out of 500 new sessions, we do not have to start from scratch. We take the posterior Beta(66, 736) as the new prior and update it with the new data:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># New posterior: Beta(66 + 40, 736 + 460) = Beta(106, 1196)\na_new &lt;- 66 + 40; b_new &lt;- 736 + 460\ncat(\"New mean:\", round(a_new\/(a_new + b_new), 3), \"\\n\")\ncat(\"New 95% CI:\", round(qbeta(c(0.025, 0.975), a_new, b_new), 3))<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>New mean: 0.081\nNew 95% CI: 0.067 0.097<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The mean stayed stable (confirming that the new data are consistent), but the interval narrowed: from [6.4%; 10.2%] to [6.7%; 9.7%]. Each new data point refines the estimate.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This property \u2014 <strong>today&#8217;s posterior is tomorrow&#8217;s prior<\/strong> \u2014 is what makes the Beta the tool of choice for Bayesian analysis of proportions, and the foundation on which more advanced tools like Bayesian A\/B testing and Thompson sampling are built.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"try-it-yourself\">Try it yourself<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A lead generation site has 12 conversions out of 350 sessions.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Calculate the posterior Beta with a non-informative prior Beta(1, 1). What are the posterior \u03b1 and \u03b2 parameters?<\/li><li>What is the mean of the posterior? And the 95% CI?<\/li><li>The site owner claims the conversion rate is at least 5%. Do the data support that? (Hint: calculate P(p \u2265 0.05) using <code>pbeta<\/code>)<\/li><li>If the same site had 120 conversions out of 3500 sessions (same raw rate, 10\u00d7 the data), how would the interval change? Why?<\/li><\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">In this article we have seen what the Beta distribution is, how \u03b1 and \u03b2 parameters determine its shape, and how it is used to estimate proportions from observed data. It is the fundamental building block of Bayesian inference for conversion rates.<br> In the next article we will take the next step: <a href=\"https:\/\/www.gironi.it\/blog\/en\/bayesian-conversion-rate-estimation\/\">estimating a conversion rate with the Beta<\/a>, using informative and non-informative priors in a concrete SEO case.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"further-reading\">Further reading<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Two books to continue: <a href=\"https:\/\/www.amazon.it\/dp\/8867319396?tag=consulenzeinf-21&amp;ascsubtag=the-beta-distribution-explained-simply\" rel=\"nofollow sponsored noopener\" target=\"_blank\"><em>Finalmente ho capito la statistica<\/em><\/a> by Maurizio De Pra (Italian edition) to place the Beta among other distributions, and <a href=\"https:\/\/www.amazon.it\/dp\/1593279566?tag=consulenzeinf-21&amp;ascsubtag=the-beta-distribution-explained-simply\" rel=\"nofollow sponsored noopener\" target=\"_blank\"><em>Bayesian Statistics the Fun Way<\/em><\/a> by Will Kurt to discover why this distribution is the queen of Bayesian inference, with R examples like the ones we use here.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This article is part of the <a href=\"https:\/\/www.gironi.it\/blog\/en\/bayesian-approach\/\">\u00abBayesian approach\u00bb<\/a> path, the curated guide to articles on Bayesian statistics and inference applied to SEO.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Imagine we have 800 sessions on a landing page and 65 conversions. The raw rate is 65\/800 \u2248 8.1%. It looks like a precise number, but is it really? Is it the true conversion probability of the page, or could it be different? And if someone claimed the page converts at least 10% \u2014 do &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":[161],"tags":[297,296],"class_list":["post-3295","post","type-post","status-publish","format-standard","hentry","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":"Imagine we have 800 sessions on a landing page and 65 conversions. The raw rate is 65\/800 \u2248 8.1%. It looks like a precise number, but is it really? Is it the true conversion probability of the page, or could it be different? And if someone claimed the page converts at least 10% \u2014 do&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":4186,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/posts\/3295\/revisions\/4186"}],"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}]}}