<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mansi Bramta on Medium]]></title>
        <description><![CDATA[Stories by Mansi Bramta on Medium]]></description>
        <link>https://medium.com/@mansibramta12?source=rss-4e5a6b578be7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nxpTHDSejTQXgqnkGs5wHw.jpeg</url>
            <title>Stories by Mansi Bramta on Medium</title>
            <link>https://medium.com/@mansibramta12?source=rss-4e5a6b578be7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 18:47:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mansibramta12/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Beyond the Formulas: Hypothesis Testing in Action]]></title>
            <link>https://medium.com/@mansibramta12/beyond-the-formulas-hypothesis-testing-in-action-bad6d2049eab?source=rss-4e5a6b578be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/bad6d2049eab</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[hypothesis-testing]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[mathematics]]></category>
            <dc:creator><![CDATA[Mansi Bramta]]></dc:creator>
            <pubDate>Sat, 14 Nov 2026 17:23:16 GMT</pubDate>
            <atom:updated>2026-11-14T17:23:16.964Z</atom:updated>
            <content:encoded><![CDATA[<h4>Hypothesis Testing in Python: Tests and Functions</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qsp7JPUaiZ7jvuFn7frXaA.jpeg" /></figure><p>Some days, I get such strong cravings that it’s hard even to explain. Just 30 minutes after dinner, I want to eat something different. And you know what makes me so happy? Zomato.</p><p>Yes, I don’t need to go anywhere. I can sit in my PJs, place an order, and the food will be delivered to my doorstep.</p><p>Don’t tell me I’m the only one who feels good about it. You’re in on this too, aren’t you?</p><p>But wait! Another website claims that it can deliver food <strong>12 minutes faster than Zomato</strong>.</p><p>OMG! Do I need to wait less? Isn’t that exciting?</p><p>It’s interesting how these claims are made and how quickly we fall for them. But are they always true? How did this website come up with such a claim? The same routes, the same restaurants, the same everything, yet somehow it’s 12 minutes faster? How can they be so sure?</p><p>Okay, so for today, I’m not Zomato. I’m the “other website.” Let’s name it <em>101 Food</em>.</p><p>So, 101 Food launched a website, and initially, its delivery times were almost the same as Zomato’s. Then, they made some changes and came up with a claim: <strong>12 minutes faster delivery</strong>.</p><p>They tested their new website and noticed that, on that particular day, they were able to deliver orders 12 minutes faster on average than their competitor.</p><p>So, the question is: Is this a valid basis for making such a claim?</p><ul><li>What if the customers who placed orders that day happened to live nearby?</li><li>What if it was Sunday and traffic was unusually light?</li><li>What if the customers ordered food that was easier to prepare, so the overall process took less time?</li></ul><p>And many more possibilities…</p><p>Can we claim that the new website is better than the old one? Can we make that decision so quickly?</p><p>The real problem is that the company hasn’t tested every possible order under every possible condition. It has tested a sample of orders.</p><p>Even if the two competitors have exactly the same average delivery time across the population we’re interested in, their observed average delivery times might differ.</p><p>Why?</p><p>Because delivery times vary. Some orders are nearby, while others are far away. Some restaurants prepare food quickly, while others take longer. The orders that happen to enter each sample can affect the results.</p><p>This is called <strong>sampling variability</strong>: sample statistics naturally fluctuate across different samples drawn from the same population.</p><p>We talked about this in my last blog, <a href="https://medium.com/@mansibramta12/can-a-small-sample-really-speak-for-a-whole-population-668a53b3b548"><strong>Can a Small Sample Really Speak for a Whole Population?</strong></a>. For a closer look at the concept, you can refer to that article.</p><p>There are two important terms worth understanding:</p><ul><li><strong>Observed difference:</strong> Suppose the old website has an average delivery time of 30 minutes, while the new one has an average delivery time of 18 minutes. The observed difference is 12 minutes.</li><li><strong>True population difference:</strong> This is the actual difference between the average delivery times of the two services across the population of orders we’re interested in. We don’t know this value exactly.</li></ul><p>The observed difference is real as a description of our samples. The uncertainty is about what it tells us regarding the wider population.</p><p>So, understanding the situation, we’re swinging between two possibilities here:</p><ol><li>The two services have the same underlying average delivery time, and the observed 12-minute difference arose because of sampling variability.</li><li>The new service genuinely has a lower average delivery time. The observed difference reflects a real improvement rather than sampling variability alone.</li></ol><p>We cannot conclude that one service is better just by looking at the 12-minute difference. We need a solid statistical basis to evaluate the claim.</p><p>But, as we learned in our previous blog, increasing the sample size can reduce the <strong>standard error</strong>. So, what if we increase our sample size?</p><p>The difference might remain close to 12 minutes, but a larger sample generally gives us a more precise estimate of that difference.</p><p>Increasing the sample size makes our estimate more precise, assuming the data are collected appropriately. But it still doesn’t guarantee that the new service performs better. A larger sample can help us distinguish a genuine difference from random variation, but it cannot eliminate every source of uncertainty.</p><p>So eventually, we end up with one important question:</p><p><em>“How can we evaluate the observed difference without assuming in advance that it is either meaningful or meaningless?”</em></p><p>Here is where we get comfortable with the term <em>hypothesis</em>.</p><p><strong>H₀ (Null Hypothesis):</strong> The old and new websites have the same population average delivery time. (The observed 12-minute difference could have occurred because of sampling variability.)</p><pre>H₀: μ_new − μ_old = 0</pre><p><strong>H₁ (Alternative Hypothesis):</strong> The new website has a lower population average delivery time than the old website. (This means the new website is genuinely faster on average.)</p><pre>H₁: μ_new − μ_old &lt; 0</pre><p>So, how should we think about this? We begin with the null hypothesis: assume there’s no genuine difference in the population until the evidence gives us sufficient reason to question that assumption.</p><p>You’ll come across two important terms ahead, and it’s important that their meanings reach you right.</p><ol><li><strong>Failing to reject the null hypothesis</strong> does not prove that the old and new websites have identical average delivery times. It only means the data did not give us enough evidence against that assumption.</li><li><strong>Rejecting the null hypothesis</strong> means the data provide sufficient statistical evidence against equal population averages, under the assumptions of the test. That is evidence in favour of the alternative hypothesis, but it is not proof, and it doesn’t automatically prove that the website changes caused the difference.</li></ol><p>Isn’t it confusing? We are not “proving” anything in either case. We are only judging how strong the evidence is. That gives us another chance to think in depth.</p><p>This is also why the questions we asked at the start (nearby customers, a light-traffic Sunday, easier-to-prepare food) cannot be answered by the test itself. A hypothesis test accounts for <em>sampling variability</em>; it cannot repair a <em>biased</em> sample. That is handled by good study design, for example by randomly assigning orders to the old and new website (an A/B test) so that both groups face similar conditions.</p><p>12 minutes is not a short time to claim in delivery apps, right? But compared to what? Imagine that differences between sample averages usually fluctuate by relatively small amounts. Then an observed difference of 12 minutes would stand out. For example, if the difference between sample averages usually fluctuates by about 2 minutes, then 12 minutes is a noticeable change. But what if it usually fluctuates by 8 minutes? Is 12 minutes still a noticeable change? Not really, right?</p><p>The formula to measure this is:</p><pre>z = (Observed difference − Hypothesized difference) / Standard error of the difference</pre><p><strong>Case A:</strong> Standard error = 2 minutes</p><pre>z = (−12 − 0) / 2 = −6</pre><p>What does −6 mean?</p><p>It means our observed difference is six standard errors below zero.</p><p>If the null hypothesis is true and the assumptions of our statistical test hold, a result this far from zero would be extremely unusual.</p><p><strong>Case B:</strong> Standard error = 8 minutes</p><pre>z = (−12 − 0) / 8 = −1.5</pre><p>Now the observed difference is only 1.5 standard errors below zero.</p><p>The actual difference is still −12 minutes. We haven’t changed the data. We’ve changed the amount of sampling variability we expect.</p><p>If the standard error is larger, the same observed difference is less extreme relative to that variability.</p><p>I chose 2 and 8 minutes as hypothetical values to demonstrate the idea. They were not calculated from actual delivery-time data.</p><p>In a real experiment, the standard error depends on the variability in delivery times, the sample sizes, and how the two sets of orders were collected.</p><p>One thing to keep in mind: a small standard error doesn’t automatically mean the new website is better. It helps us assess whether the observed difference is surprising under the assumption of no genuine improvement.</p><p>That brings us to our next topic, the “<strong>significance level</strong>”.</p><p>How strong should our evidence be before we reject the null hypothesis?</p><p>Before answering that, let’s understand the two ways a decision can go wrong. Think of it in terms of 101 Food’s claim:</p><ul><li><strong>Type-I error (false positive):</strong> The new website is actually <em>not</em> faster, but our test says it is. We reject the null hypothesis when it is actually true. It’s like a false alarm.</li><li><strong>Type-II error (false negative):</strong> The new website is <em>actually</em> faster, but our test fails to detect it. We fail to reject the null hypothesis when it is actually false. It’s like a missed alarm.</li></ul><p>These errors are always possible in statistics, because we are drawing conclusions about a population from a sample.</p><p>We will usually hear about the 5% significance level.</p><p>Suppose the null hypothesis is true (for example, the two services really have the same average delivery time). If we repeatedly conducted the same hypothesis test on new samples, a test using a 5% significance level would have a 5% probability of rejecting the null hypothesis incorrectly, under the test’s assumptions. This is a Type I error: rejecting the null hypothesis when it is actually true. The significance level (α) sets the maximum probability of this error that we are willing to tolerate for the test. It does not mean there is a 5% probability that our particular null hypothesis is true.</p><p>This is very important to understand as we move on to the <strong>p-value</strong>.</p><p>The <strong>p-value</strong> is the probability of getting a result at least as extreme as the one we observed, <em>assuming the null hypothesis is true</em>. A very small p-value means our result would be very surprising if the null hypothesis were true. It is not the probability that the null hypothesis is true.</p><p>Before we come to a result, we want to establish a rule first, which for the 5% significance level looks something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*46HwOp_32Mi6GP-e4Lc6rA.png" /></figure><ul><li>If the evidence is strong enough that the p-value is 0.05 or lower, we reject the null hypothesis.</li><li>If the p-value is greater than 0.05, we fail to reject the null hypothesis.</li></ul><p>Now that we understand what the <strong>significance level</strong> and <strong>p-value</strong> mean, one more thing to learn here is <strong>One-Tailed and Two-Tailed Tests</strong>.</p><p>This is not much of a task to understand. We only need to know which direction we are talking about. In our example, we only want to see whether the 2nd website is faster than the 1st one, and that is a <em>One-Tailed Test</em>. But what if we never knew whether the second website was faster or slower at delivering orders? Then it would be a <em>Two-Tailed Test</em>, because we do not know the direction. In a two-tailed test, we look at extreme results in both tails of the distribution.</p><p>Now is the perfect time to see it practically, as all the theoretical knowledge is consumed. So let’s see the steps to calculate and analyse the p-value.</p><p><strong>Step 1: Calculate a test statistic, such as a z-score or t-score.</strong></p><p>In our case, we are dealing with a <em>One-Tailed Test</em>, and some of the things we already know are:</p><ul><li>App A (old website) average delivery time = 30 minutes</li><li>App B (new website) average delivery time = 18 minutes</li><li>Standard error of the difference = 2 minutes</li></ul><p>To keep the arithmetic positive, let A = old and B = new, so the claim “the new website is faster” now reads μ_A − μ_B &gt; 0 (this is the same claim as μ_new − μ_old &lt; 0, just with the sign flipped).</p><p>So our hypotheses are:</p><pre>H₀: μ_A − μ_B = 0<br>H₁: μ_A − μ_B &gt; 0</pre><p>We will use a <em>z-score</em> because, for this example, we assume that the population standard deviation is known.</p><p>We calculate the test statistic:</p><pre>z = (Observed difference − Difference under H₀) / Standard error of the difference</pre><p>Substituting our values:</p><pre>z = ((30 − 18) − 0) / 2 = 12 / 2 = 6</pre><p>Our z-statistic is 6.</p><p><strong>Step 2: Use the appropriate probability distribution to find the probability of a result at least as extreme as the observed one.</strong></p><p>The z-distribution is the standard normal distribution, which has a mean of 0 and a standard deviation of 1. When a test statistic follows this distribution under the null hypothesis, we can use it to calculate the probability of observing a result as extreme as ours. For our worked example, we assumed that the test statistic follows a standard normal distribution.</p><p><strong>One important distinction: we cannot choose the z-distribution just because we calculated a z-score.</strong> In a real study, whether a z-test or t-test is appropriate depends on what we know about the population, the sample data, and the assumptions of the test.</p><p>Because this is a one-tailed test with the alternative hypothesis H₁: μ_A − μ_B &gt; 0, we look at the area to the right of z = 6.</p><p>We want to find:</p><pre>p = P(Z ≥ 6)</pre><p>Under the null hypothesis, the expected difference is zero. We now look for results that would support our alternative hypothesis: differences that are even more positive than the one we observed. That means looking at z = 6 and values greater than 6.</p><p>Using the standard normal distribution:</p><pre>p ≈ 9.87 × 10⁻¹⁰<br>p ≈ 0.000000000987</pre><p>This is an extremely small probability, and most z-tables do not have values as large as z = 6, so we can always use Python:</p><pre>from scipy.stats import norm<br><br>p_value = norm.sf(6)<br>print(p_value)<br># Output:<br># 9.865876450376946e-10</pre><p><strong>Step 3: That probability is the p-value.</strong></p><p>If the two apps truly have the same population mean delivery time, the probability of observing a difference at least as large as 12 minutes in the direction specified by our alternative hypothesis is approximately 0.0000000987%, under our assumptions. This provides extremely strong evidence against the null hypothesis. If we use a significance level of α = 0.05, then p &lt; 0.05.</p><p>Therefore, we reject the null hypothesis. Our results provide strong statistical evidence that App A’s true average delivery time is greater than App B’s.</p><p>After all of this, a question remains: can we be sure we have reached the right conclusion? As I discussed above with <em>Type-I</em> and <em>Type-II</em> errors, we are drawing conclusions about a population from a sample, so there is always a chance of error.</p><p>Now we come to the most important part: finding the right statistical test.</p><p>For that, we first need to find:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*T-yO6SMuCxf0386jPSTWfA.png" /></figure><p>There are many tests, like:</p><p><strong>1. Z-tests</strong></p><ul><li>One-sample Z-test for a mean</li><li>Two-sample Z-test for means</li><li>One-proportion Z-test</li><li>Two-proportion Z-test</li></ul><p><strong>2. T-tests</strong></p><ul><li>One-sample T-test</li><li>Independent two-sample T-test</li><li>Paired-sample T-test</li></ul><p><strong>3. Chi-square tests</strong></p><ul><li>Chi-square test of independence</li><li>Chi-square goodness-of-fit test</li></ul><p><strong>4. ANOVA tests</strong></p><ul><li>One-way ANOVA</li><li>Two-way ANOVA</li><li>Repeated-measures ANOVA</li></ul><p><strong>5. Correlation tests</strong></p><ul><li>Pearson correlation test</li><li>Spearman rank correlation test</li><li>Kendall’s tau correlation test</li></ul><p><strong>6. Non-parametric tests</strong></p><ul><li>Mann–Whitney U test</li><li>Wilcoxon signed-rank test</li><li>Kruskal–Wallis test</li><li>Friedman test</li></ul><p><strong>7. Variance tests</strong></p><ul><li>F-test for equality of two variances</li><li>Levene’s test</li><li>Bartlett’s test</li></ul><p><strong>8. Other useful tests for Data Science</strong></p><ul><li>Fisher’s exact test</li><li>McNemar’s test</li><li>Kolmogorov–Smirnov test</li><li>Shapiro–Wilk test</li><li>Breusch–Pagan test</li><li>Durbin–Watson test</li></ul><p>It would make our blog too much to handle if we covered all of them, so I will cover the first four families (Z-tests, T-tests, Chi-square tests and ANOVA), along with the Pearson correlation test.</p><p>So first we start with <strong>Z-tests</strong>:</p><p>A z-test can be performed on one sample as well as on two samples, but what we need to know is whether we are comparing them on the basis of a mean or a proportion. Here I have classified the z-tests on the basis of mean as well as proportion, so go through them, but remember not to memorize them. We will discuss how we ended up with these formulas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*7EZbj8vDvD5VGv_d-so7uw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*vM-AUQMY8Rvz-5S2bVRbWw.png" /></figure><p>So now that you have read them, let’s unfold how we got here.</p><p>Imagine a food delivery company claims that the average delivery time is 30 minutes. You collect a sample of 100 deliveries and find that their average delivery time is 33 minutes. Now you have a question:</p><p>Is the difference of 3 minutes meaningful, or could it have happened just because you selected a sample instead of checking every delivery? To answer this, we need to compare two things:</p><ul><li>The difference we observed: 33 − 30 = 3 minutes.</li><li>The amount of variation we normally expect from sample to sample.</li></ul><p>That’s the entire idea behind a z-test.</p><p>Here the difference is 3 minutes, but is it large or small? Compared to what? That is what matters.</p><p>That’s how we arrive at the basic z-test formula:</p><pre>Z = (Observed − Expected under H₀) / (Standard error under H₀)</pre><p>The numerator tells us how far our result is from the claim. The denominator tells us how large that difference is compared with the uncertainty in our sample.</p><p>In the same way, all four z-tests get their formulas. In fact, each one is built exactly like this.</p><p>Talking about the tests, one must also know which distribution to use for which test, and why. Once we are clear about which test to use and have found the test statistic, we must know whether the value is large or small, and whether it is reasonable or unusual enough to support a claim.</p><p>That’s where the distributions come in. We have the <strong>standard normal (Z) distribution</strong>, the <strong>t-distribution</strong>, the <strong>Chi-square distribution</strong> and the <strong>F-distribution</strong>.</p><p>Specifically, for the <strong>z-tests on means</strong> we use the <strong>z-distribution</strong> because the population standard deviation is known. For the <strong>z-tests on proportions</strong>, the standard error is calculated from the proportion assumed under H₀, and we use the normal distribution as an approximation when the sample is large enough.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*LpoAbSVVe7In1NHuEWPTXw.png" /></figure><p>After knowing the test and the distribution, we compare the p-value (coming from the z-distribution) with the accepted significance level.</p><p>Our rule is:</p><ul><li>If p-value ≤ α, reject H₀.</li><li>If p-value &gt; α, fail to reject H₀.</li></ul><p>Then comes the <strong>t-test</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*OJ3WCupZzyPVTQsm1aCkPQ.png" /></figure><p>We now know how we ended up with the test statistic, but something new here is <em>degrees of freedom</em>. Calculating the t-statistic is only half the job. We also need to know whether that t-value is unusual enough to reject the null hypothesis. For that, we use the t-distribution.</p><p>For all standard t-tests, we use the t-distribution to calculate the p-value or find the critical value. As explained above, in a t-test we do not know the population standard deviation, so we use the sample standard deviation instead. That’s why the t-distribution makes sense here.</p><p>Here’s the important part: the shape of the t-distribution depends on the degrees of freedom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*rUQpYkgd1ymodXmt4GoFHg.png" /></figure><p>Smaller df → heavier tails and more uncertainty. Larger df → the t-distribution gets closer to the normal distribution.</p><p>So, we need df to choose the correct t-distribution and calculate the p-value or critical t-value. But why does df affect the distribution? To understand that, let’s look at what df actually means.</p><p>I have explained <em>degrees of freedom</em> in my previous blogs. Do check them out for a more detailed explanation. Here I will give a glimpse: degrees of freedom usually means the number of independent pieces of information (values that are free to vary) that go into an estimate. For example, if we know the mean of three numbers, only two of them are free to vary, and the third can be calculated from the mean and the other two. That is why, for one sample, the degrees of freedom are <em>n − 1</em>.</p><p>But how do we get the degrees of freedom for the <strong>independent two-sample t-test</strong>? For the pooled independent two-sample t-test, we estimate the variability of each group and combine those estimates to calculate a pooled variance. Since we estimate two means (one for each group), the degrees of freedom are:</p><pre>df = n₁ + n₂ − 2</pre><p>This is used when both populations are assumed to have the same variance. It combines their variance estimates into one pooled estimate.</p><p><em>Welch’s independent t-test</em> uses the more complicated formula shown above. It does not assume that the two populations have equal variances. It adjusts the degrees of freedom based on the sample sizes and the two sample variances.</p><p>Because the two groups may have different variances, Welch’s test cannot treat their variance estimates as equally informative. Its formula approximates the effective degrees of freedom for the combined standard error. That is why its df can be a decimal, such as 14.7, rather than a whole number like 20. It is an approximation, not a count of literal people or observations.</p><p>So the rule to remember here is: with fewer degrees of freedom, you need a more extreme t-value to reject the null hypothesis at the same significance level.</p><p>For a two-tailed test at the 5% significance level, the critical t-values are approximately:</p><ul><li>df = 4 ±2.776</li><li>df = 10 ±2.228</li><li>df = 30 ±2.042</li><li>df = 99 ±1.984</li></ul><p>To reject the null hypothesis, the absolute value of our t-statistic must be greater than the critical value for the respective df.</p><p>Now, <strong>Chi-square tests</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*u7YsIzRq6j7pSU5NzFEcRA.png" /></figure><p>The chi-square test statistic measures how far the observed frequencies are from the expected frequencies. If the observed and expected frequencies are very similar, the chi-square statistic will be small. If they differ substantially, the statistic will be large, suggesting evidence against the null hypothesis.</p><p>We use the <strong>chi-square distribution</strong> for <strong>Chi-square tests</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*gcU7o3EKT_Ty7gMVbYetBg.png" /></figure><p>After getting the respective <em>degrees of freedom</em>, we look up the critical value in the chi-square distribution table for the chosen significance level. If our chi-square statistic is greater than the critical value, we reject the null hypothesis. Equivalently, in terms of the p-value:</p><p>The chi-square test is a right-tailed test, because only large values of the statistic indicate that the observed and expected frequencies differ.</p><ul><li>If p-value ≤ α, reject H₀.</li><li>If p-value &gt; α, fail to reject H₀.</li></ul><p><em>Expected frequency</em> gives us a reference point. Without it, we wouldn’t know whether the observed counts are unusual. However, the way we calculate expected frequency differs between the two tests. For goodness-of-fit, the expected count for each category is the total sample size multiplied by the hypothesized proportion for that category. For independence, the expected count for each cell is (row total × column total) / grand total. So, goodness-of-fit checks whether observed counts match a specified distribution, while independence checks whether two categorical variables are associated.</p><p>The degrees of freedom for the test of independence are <em>(r − 1)(c − 1)</em>, because the row and column totals constrain the cell counts. Once the margins and enough cells are known, the remaining cells are determined. That is how we count the number of independently varying cells. For goodness-of-fit, the degrees of freedom are <em>k − 1</em>, where k is the number of categories (when no parameters are estimated from the data).</p><p><strong>ANOVA tests</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/1*oN0jqLs-PEpsH2bN9YyPLQ.png" /></figure><p>ANOVA tests whether the means of three or more groups are all equal. The null hypothesis says all population means are equal, and the alternative says at least one mean is different.</p><p>The ANOVA test statistic (F-statistic):</p><pre>F = Variation between groups / Variation within groups</pre><p>can be simply explained like this. Let us assume a school has sections A, B and C, and we took the marks of three students from each section in a particular subject. If we measure how much the section averages differ from each other, that is called <strong>Variation between groups</strong>. If we measure how much the students’ marks vary inside a particular section, that is called <strong>Variation within groups</strong>.</p><p>To get the results here, we use the <strong>F-distribution</strong>. The F-distribution depends on two degrees of freedom:</p><ul><li>Numerator degrees of freedom: associated with the between-group variation (k − 1, where k is the number of groups).</li><li>Denominator degrees of freedom: associated with the within-group variation (N − k, where N is the total number of observations).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*qpa-2PQPSZtoY9QQJaIYiA.png" /></figure><p>After knowing the degrees of freedom of the numerator and denominator, we look up the critical value in the F-distribution table for the chosen significance level. If our F-statistic lies to the right of the critical value (equivalently, if p ≤ α), we reject the null hypothesis. ANOVA is a right-tailed test.</p><p>In more formal language, a large F-statistic provides evidence that not all population means are equal, and a small F-statistic means the observed differences between means are small compared with the variation within groups.</p><p>A large F-statistic is evidence against the null hypothesis, but we determine statistical significance using the F-distribution and the p-value, which also depend on degrees of freedom.</p><p>If the groups look very different compared with the natural variation within them, that difference is harder to explain by random sampling alone. That’s why ANOVA divides one by the other.</p><p>MS condition (mean square between groups) measures variation between group means; MS error (mean square within groups) measures variation within groups. The F-statistic compares these two quantities to assess whether the group means differ more than we’d expect from ordinary within-group variation alone.</p><p>One more thing: ANOVA only tells us that <em>at least one</em> mean is different. It does not tell us <em>which</em> one. For that, we use follow-up (post-hoc) tests such as Tukey’s HSD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*y-m3YBH10yQvqDQ_yKDVHg.png" /></figure><p><strong>Correlation tests</strong>: Pearson correlation test</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*vxQuv0l8cgUChS7aHuGnKQ.png" /></figure><p>The sample correlation r tells us the direction and strength of the observed linear relationship. But we also need to determine whether the observed correlation provides enough evidence against H₀, where H₀: ρ = 0 (no linear correlation in the population) and H₁: ρ ≠ 0. The test statistic converts the sample correlation into a t-value:</p><pre>t = r × √(n − 2) / √(1 − r²)</pre><p>The formula accounts for both the observed correlation and the sample size. The resulting t-statistic tells us how extreme the observed correlation is under the null hypothesis of zero population correlation.</p><p>Pearson’s correlation involves two variables, X and Y. When calculating their sample correlation, we estimate two sample means. These two estimated means impose two constraints on the deviations used in the calculation. This leads to n − 2 degrees of freedom in the standard test.</p><p>For Pearson’s correlation test, we use the t-distribution to test whether the population correlation coefficient is significantly different from zero. The degrees of freedom determine which t-distribution we use to calculate the p-value.</p><p>Reject H₀ if p ≤ α (for example, α = 0.05).</p><p>Remember that a significant correlation only shows a linear association. It does not prove that one variable causes the other.</p><p>Import these libraries in Python to run these tests:</p><pre>from scipy import stats<br>from statsmodels.stats.weightstats import ztest<br>from statsmodels.stats.proportion import proportions_ztest<br>import statsmodels.api as sm<br>from statsmodels.stats.anova import AnovaRM</pre><p>Use these functions:</p><pre># Z-tests<br>ztest()<br>proportions_ztest()<br><br># T-tests<br>stats.ttest_1samp()<br>stats.ttest_ind()      # pooled by default; use equal_var=False for Welch&#39;s t-test<br>stats.ttest_rel()      # paired t-test<br><br># Chi-square tests<br>stats.chisquare()          # goodness-of-fit<br>stats.chi2_contingency()   # test of independence<br><br># Pearson correlation test<br>stats.pearsonr()<br><br># ANOVA tests<br>stats.f_oneway()       # One-way ANOVA<br>sm.stats.anova_lm()    # Two-way ANOVA (used on a fitted OLS model)<br>AnovaRM()              # Repeated-measures ANOVA</pre><p>Before concluding my blog, I want to give you an important distinction.</p><p><strong>Hypothesis testing vs Confidence interval</strong></p><ul><li>Hypothesis testing helps you decide whether the data provide enough evidence against a particular claim.</li><li>A confidence interval helps you understand which values are reasonably compatible with the observed data and how precise your estimate is.</li></ul><p>The two are closely linked. For example, if a 95% confidence interval for the difference in means does not contain 0, a two-tailed test at the 5% significance level would reject H₀.</p><p>Because these are screenshots, the image resolution is not good. You can view the tables directly in the PDF here: <a href="https://github.com/MansiBramta/hypothesis-testing-blog/blob/main/tests.pdf"><em>View the table in PDF format</em></a></p><p>Before ending this blog, I would highly suggest spending more time with these tests by solving problems related to each one of them. That will surely make things clearer for you. You can also go through my other blogs, where I have explained some concepts in an easier way. Till then, <strong>Happy Learning</strong>.</p><h3>Code and Notebook</h3><p>All the code from this walkthrough is available here:</p><ul><li><a href="https://www.kaggle.com/code/mansibramta/beyond-the-formulas-hypothesis-testing-in-action"><strong>Kaggle notebook</strong></a></li><li><a href="https://github.com/MansiBramta/hypothesis-testing-blog"><strong>GitHub repository</strong></a></li></ul><h3>Connect With Me</h3><p>If you found this useful, I’d love to connect and hear your feedback:</p><ul><li><a href="http://www.linkedin.com/in/mansi-bramta-65358741b"><strong>LinkedIn</strong></a></li><li><a href="https://github.com/MansiBramta"><strong>GitHub</strong></a></li><li><a href="https://www.kaggle.com/mansibramta"><strong>Kaggle</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bad6d2049eab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Skewness & Kurtosis: From Moments to Machine Learning]]></title>
            <link>https://medium.com/@mansibramta12/skewness-kurtosis-from-moments-to-machine-learning-7964a9170043?source=rss-4e5a6b578be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/7964a9170043</guid>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Mansi Bramta]]></dc:creator>
            <pubDate>Sat, 24 Oct 2026 06:40:53 GMT</pubDate>
            <atom:updated>2026-10-24T06:40:53.457Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>The mathematics, intuition, interpretation, and practical use of higher-order moments.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QazT8nQMJbp9Ozl6j20TiA.png" /></figure><h4>1. Why We Need Samples: Population vs. Sample</h4><p>Would it be practical if I said, <strong>“I want to find out the average marks of Class 12 students in the Non-Medical stream all over India”?</strong></p><p>I mean, who is going to visit every school in India, across every state, every district, and every village? That is next to impossible. And even if we somehow managed to collect all that data, it would require an enormous amount of time, money, and effort, with plenty of opportunities for errors and inconsistencies along the way.</p><p>So, can this problem not be solved?</p><p><em>Absolutely!</em></p><p>We can solve it using one of the most important concepts in statistics: <strong>Population vs. Sample</strong> .</p><p>I want you to look at this beautifully explained image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D_CWOSPHjvztSq8W3p49gQ.png" /></figure><p>As shown above, a <em>subset</em> of a population is known as a sample.</p><p>When the data is too large to collect or compute, we often use sample data instead. But there is one important condition: the sample should be <strong>representative of the population</strong> and should not introduce systematic <em>bias</em>. This means that we should not select only a particular group of people in a way that could easily alter the outcome.</p><p>For example, if I only consider students who have scored 90% or above, the average marks will naturally be very high. But if we consider students with all kinds of marks, ranging from low to high, the sample is more likely to represent the actual population, and therefore, the results are more likely to be closer to the true population value.</p><p>The size of the population is denoted by <em>N</em>, while the size of the sample is denoted by <em>n</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*YXBRj7VJSyncXot9JY62cg.png" /></figure><h4>2. Why Divide by n − 1? Degrees of Freedom Explained</h4><p>Here, a question may arise — why, in a sample, are we dividing by (n-1) and not by (n)?</p><p>To clear this confusion up, we need to learn something important.</p><p><strong>Do we know that the sum of deviations from the mean is always 0?</strong></p><p>Here is a small proof.</p><p>This is our sample mean, right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/191/1*E83fleF-fJxqDcEuccOquA.png" /></figure><p>If we multiply both sides by (n),</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/192/1*ql09TohqrAozXpTCYxymLg.png" /></figure><p>After expanding, we will get something like this, which means the sum of the deviations of each sample point from the mean:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/1*e0WxWq2jyUbsZBWXnYs7gg.png" /></figure><p>It will always be 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/131/1*eQIYqR1wqF6hGA6YUHH6ow.png" /></figure><p>Now, according to this, let’s notice something.</p><p>Suppose we have three deviations:</p><p>-2, 0, ?</p><p>Do we really need all three deviations?</p><p>From the other two, I can easily say that the third one has to be (+2). That’s the only value that will make the sum equal to 0.</p><p>So, out of these 3 deviations, we can independently choose only 2. The last one is automatically determined by the other two.</p><p>Therefore, in general, if we have (n) deviations from the sample mean, only (n-1) of them can vary independently because their sum must be 0.</p><p>And this is where we get our first intuition for <em>Degrees of Freedom.</em></p><p>But there is one more important point.</p><p>When we calculate sample variance, we are using the sample mean instead of the true population mean. Because of this, dividing by (n) would systematically make our estimate of variance a little too small.</p><p>Dividing by (n-1) corrects this bias and gives us an unbiased estimate of the population variance.</p><p>And that’s how, unknowingly, you became familiar with the concept of <strong>Degrees of Freedom</strong>.</p><p>Now you might be wondering: why did we take such a long route through <em>populations</em>, <em>samples</em>, and <em>degrees of freedom</em> before even talking about skewness?</p><p>Because skewness and kurtosis are statistical measures, and to properly understand their formulas, we need to understand where population and sample formulas come from.</p><h4>3. Moments: The Building Blocks of Shape</h4><p>Before we move on to our main topic, I want us to learn one more important concept first, <strong>Moments</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sXo8ShsosdywEf1L_nTCAg.png" /></figure><p>We have four <strong>central moments</strong>:</p><p>- <strong>First Central Moment → 0</strong></p><p>- <strong>Second Central Moment → Variance</strong></p><p>- <strong>Third Central Moment → Related to Skewness</strong></p><p>- <strong>Fourth Central Moment → Related to Kurtosis</strong></p><p>We have already gone through the <em>Mean</em> and <em>Variance</em>, which correspond to the <strong>first raw moment and second central moment</strong>, respectively.</p><p>For this blog, we will take a deep dive into the <strong>Third and Fourth Central Moments</strong> and see how, after standardization, they lead to measures of <strong>Skewness and Kurtosis.</strong></p><p>— <strong>First Central Moment </strong>→ <strong>0</strong> →</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/191/1*5h8n0mg-fIEEhDef0QANCQ.png" /></figure><p>— <strong>Second Central Moment → Variance →</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/199/1*VzX_T9V8cyMOfRQ5WvXomg.png" /></figure><p>— <strong>Third Central Moment → Related to Skewness</strong> →</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/192/1*RFDQ-HEnYvTiuZqfL_QwMA.png" /></figure><p>— <strong>Fourth Central Moment → Related to Kurtosis</strong> →</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/192/1*FUnC4N3mZYAOB0uo7YLkzw.png" /></figure><p>These <strong>population moments</strong> are defined using the <strong>population distribution</strong>.</p><p>If we want to calculate the corresponding sample moments, we replace the population expectation with the corresponding sample average.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/1*L5NirkZDwGkHBoM0UuKO1Q.png" /></figure><h4>4. Skewness: Measuring Asymmetry</h4><h4>4.1 Symmetric vs. Skewed Distributions</h4><p>Now we have everything we need to understand our main topic of interest, so let us begin by first understanding what a <strong>Distribution</strong> is.</p><p>→ <em>A distribution describes how the values of a variable are distributed and how frequently different values or ranges of values occur. We can simply think of it as a map of our data.</em></p><p>This map could be <em>Symmetric</em> or <em>Non-Symmetric</em>.</p><p><em>Symmetric</em> as in:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*1MyPcuylMEFD1GuQunfRng.png" /></figure><p>And <em>non-symmetric distributions</em> are further classified into two types — <strong>right-skewed and left-skewed distributions</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RTK67MGlisQHed8KtnaHYw.png" /></figure><p>People often get confused because they consider the side with more of the distribution to be the side corresponding to its name. But there is one key thing to remember, always look at the <em>tail</em>.</p><p>If the long tail extends toward the <em>right</em>, then it is <strong>Right-Skewed (Positively Skewed)</strong>.</p><p>And if the long tail extends towards the <em>left</em>, then it is <strong>Left-Skewed (Negatively Skewed)</strong>.</p><p>Here is the Python code generated using 1,000 random data points, showing right-skewed, normal, and left-skewed distributions.</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from scipy.stats import gaussian_kde<br><br># Generate data<br>np.random.seed(42)<br><br># Positive skewness (right-skewed)<br>positive = np.random.exponential(scale=2, size=1000)<br><br># Normal distribution<br>normal = np.random.normal(loc=5, scale=1, size=1000)<br><br># Negative skewness (left-skewed)<br>negative = -np.random.exponential(scale=2, size=1000)<br><br><br># Function to plot distribution<br>def plot_distribution(data, title):<br><br>    # Mean<br>    mean = np.mean(data)<br><br>    # Median<br>    median = np.median(data)<br><br>    # KDE<br>    kde = gaussian_kde(data)<br><br>    x = np.linspace(min(data), max(data), 1000)<br>    y = kde(x)<br><br>    # Mode = x-value where KDE is maximum<br>    mode = x[np.argmax(y)]<br><br>    # Plot histogram<br>    plt.hist(<br>        data,<br>        bins=30,<br>        density=True,<br>        alpha=0.5<br>    )<br><br>    # KDE curve<br>    plt.plot(<br>        x,<br>        y,<br>        linewidth=2,<br>        label=&quot;KDE&quot;<br>    )<br><br>    # Mean<br>    plt.axvline(<br>        mean,<br>        linewidth=2,<br>        color = &#39;red&#39;,<br>        label=f&quot;Mean = {mean:.2f}&quot;<br>    )<br><br>    # Median<br>    plt.axvline(<br>        median,<br>        linewidth=2,<br>        color = &#39;green&#39;,<br>        label=f&quot;Median = {median:.2f}&quot;<br>    )<br><br>    # Mode<br>    plt.axvline(<br>        mode,<br>        linewidth=2,<br>        color = &#39;black&#39;,<br>        label=f&quot;Mode ≈ {mode:.2f}&quot;<br>    )<br><br>    plt.title(title)<br>    plt.xlabel(&quot;Values&quot;)<br>    plt.ylabel(&quot;Density&quot;)<br>    plt.legend()<br>    plt.show()<br><br><br># Plot all three<br>plot_distribution(positive, &quot;Positive Skewness (Right-Skewed)&quot;)<br>plot_distribution(normal, &quot;Normal Distribution&quot;)<br>plot_distribution(negative, &quot;Negative Skewness (Left-Skewed)&quot;)</pre><h4>4.2 Mean, Median and Mode in Skewed Data</h4><p>One more thing we should look at and observe is how the <strong>Mean</strong>, <strong>Median</strong>, and <strong>Mode</strong> are positioned in these three distributions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*O_rlPjp6B0DO2kOjNPKYwA.png" /></figure><p>For a <strong>Left-Skewed </strong><em>(negatively skewed)</em> distribution -&gt; <strong>Mean</strong> &lt; <strong>Median</strong> &lt; <strong>Mode</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*E2WQWUZQ1DHUwuW-DLfZug.png" /></figure><p>For a <strong>symmetric normal</strong> distribution, we generally observe -&gt; <strong>Mean</strong> ≈ <strong>Median</strong> ≈ <strong>Mode</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*7Z5eerZiolG9FIGD77TSpQ.png" /></figure><p>For <strong>Right-Skewed</strong> <em>(Positively skewed)</em> distribution we often observe -&gt; <strong>Mean</strong> &gt; <strong>Median</strong> &gt; <strong>Mode</strong>.</p><p>The stretch in the tail of a skewed distribution can sometimes be caused by extreme values or outliers on one side of the distribution. However, skewness does not always mean that outliers are present, the distribution itself can naturally have a longer tail on one side.</p><h4>4.3 From the Third Central Moment to Skewness</h4><p>So, moving forward, we have already seen a mathematical glimpse of skewness above while I was explaining the concept of Moments.</p><p>— <strong>Third Central Moment → Related to Skewness</strong> →</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/192/1*RFDQ-HEnYvTiuZqfL_QwMA.png" /></figure><p>As we can see above, I have mentioned it as <strong>Related to Skewness</strong>, not <strong>Skewness</strong> itself. And that perfectly leads us to an important question: <strong>Why are we standardizing it here?</strong></p><p>We just need to standardize it a little bit so that the resulting measure becomes independent of the scale of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/176/1*vmHtSxLadjcJNYHi6791OA.png" /></figure><p>Here, we divide the <strong>Third Central Moment</strong> by the <strong>cube of the Standard Deviation.</strong></p><p>The Third Central Moment has a <strong>cubed unit</strong>, such as (cm³), (km³), etc. But we don’t want our skewness value to depend on the unit in which our data is measured.</p><p>So, by dividing it by the cube of the Standard Deviation, we cancel out the units and get a <strong>unitless (dimensionless) value</strong>.</p><p>One more important question here could be: <strong>Why do we need to use the third power? Why not square it?</strong></p><p><strong>(X — μ)</strong></p><p>represents the distance of a data point from the mean.</p><p>If we <strong>square</strong> this distance, both positive and negative deviations become positive. So, we would lose information about the <strong>direction</strong> of the deviation.</p><p>But when we <strong>cube</strong> it, something interesting happens:</p><p>(+2)³ = +8</p><p>while</p><p>(-2)³ = -8</p><p>The sign is preserved!</p><p>This allows the <strong>Third Central Moment</strong> to capture the direction of <strong>asymmetry around the mean.</strong></p><p>There is another important point here. Cubing also gives much greater weight to large deviations. For example:</p><p>2³ = 8, 5³ = 125</p><p>So, extreme values have a much stronger influence on the Third Central Moment. This is one of the reasons why skewness is particularly sensitive to <strong>extreme values and outliers</strong>.</p><h4>4.4 Sample Skewness: Fisher–Pearson and Bias Correction</h4><p>Now, one more important thing to mention, the formulation we saw above is for <strong>Population</strong> data.</p><p>But in most real-world problems, we rarely have access to the entire population. We usually work with a <strong>Sample</strong>.</p><p>Therefore, we need to adjust the <em>population</em> formulation when calculating skewness from <em>sample data</em>.</p><p>This adjustment leads us to the <strong>Fisher–Pearson sample skewness coefficient</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*TYJT_yY8703z0uKoFrg32w.png" /></figure><p>On looking at the formula for the first time, it might look scary, but it is actually quite simple.</p><p>It is basically the <strong>third sample central moment divided by the (3/2)-power of the second sample central moment.</strong></p><p>The intuition here is:</p><p>- The <strong>Third Sample Central Moment</strong> tells us about the <strong>asymmetric behaviour</strong> of the data.</p><p>- The <strong>Second Sample Central Moment</strong> tells us about the <strong>spread or scale of the data</strong>.</p><p>So, by dividing the third moment by the (3/2) power of the second moment, we are essentially asking,</p><p><strong>How much asymmetry is there relative to the scale of the data?</strong></p><p>This standardization is important because we don’t want our skewness value to depend on the units or scale of the data.</p><p>But even this estimator has a limitation- it can be biased, particularly for small sample sizes.</p><p>Think about it this way, if we repeatedly take different samples from the same population and calculate the skewness of each sample, the values will fluctuate. If we take the average of these sample skewness estimates over many repeated samples, it may systematically differ from the actual population skewness.</p><p>We wouldn’t simply call this difference a mistake. When an estimator systematically tends to overestimate or underestimate the quantity we are trying to estimate, this systematic difference is called <strong>Bias</strong>.</p><p>So, we need a <strong>correction factor</strong>, let’s call it <em>C(n)</em>.</p><p>We can write:</p><p>G_1 = C(n)* g_1</p><p>This correction factor is derived from the expected behaviour of the sample skewness estimator under repeated sampling.</p><p>This leads us to the <strong>Adjusted Fisher–Pearson Skewness Coefficient</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/1*o_F4IXsadMiTOlGCKl675A.png" /></figure><p>The adjustment slightly changes the estimate to compensate for the systematic bias present in the unadjusted sample skewness.</p><p>And as the sample size becomes very large, the correction factor approaches (1), so:</p><p>G_1 → g_1</p><p>In other words, <strong>for large samples, the difference between the adjusted and unadjusted skewness becomes very small.</strong></p><p>Here, as we can see, the correction factor only depends on (n). But why not something else?</p><p>→ <em>We don’t want to calculate a different correction based on whether the data is measured in ₹100, ₹10,000, heights, salaries, etc.</em></p><p>The problem we are correcting is primarily a <strong>finite-sample problem</strong>.</p><p>So, the correction should depend on the <strong>Sample Size</strong> rather than the actual values or units of the data.</p><h4>4.5 How to Interpret Skewness Values</h4><p>Now, the last thing we need to discuss is the <strong>value of skewness we will get.</strong></p><p><strong>How will we classify whether our data is highly skewed or mildly skewed?</strong></p><p>There isn’t a universal mathematical rule for this because the interpretation of skewness depends heavily on the <strong>context and the data</strong>.</p><p>As a rough rule of thumb:</p><p>- If <strong>Skewness approx 0</strong> → the data is <strong>approximately symmetric</strong>.</p><p>- If <strong>Skewness is positive</strong> → the distribution is <strong>Right-Skewed</strong>.</p><p>- If <strong>Skewness is negative</strong> → the distribution is <strong>Left-Skewed</strong>.</p><p>- If <strong>|Skewness| is large</strong> → the distribution shows a <strong>stronger degree of asymmetry.</strong></p><p>But context matters.</p><p>A skewness value of <em>1</em> might be perfectly acceptable in one context and problematic in another. There is no single cutoff that can tell us whether skewness is “good” or “bad” for every dataset.</p><p>Let us see this through Python code as well, using the same random dataset I showed above.</p><pre>from scipy.stats import skew<br><br>print(&quot;Positive skewness:&quot;, skew(positive))<br>print(&quot;Normal skewness:&quot;, skew(normal))<br>print(&quot;Negative skewness:&quot;, skew(negative))</pre><p>Positive skewness: 1.865034222864843</p><p>Normal skewness: -0.036662811518565</p><p>Negative skewness: -1.6510942321423066</p><p>From the above results, we can clearly see that the <strong>’+’ and ‘-’ signs show us the direction of skewness</strong>.</p><p>We can also see that the <strong>Normal Skewness</strong> is slightly negative. We can treat it as <strong>approximately symmetric</strong>. However, a skewness value close to zero alone does not prove that the distribution is <strong>normally distributed</strong>. Therefore, we would not consider this distribution to be meaningfully left-skewed based on its skewness value alone.</p><p>We can also clearly see that the <strong>Positive Skewness</strong> is greater in magnitude than the <strong>Negative Skewness</strong>.</p><p>But remember, we do <strong>not</strong> compare them simply because a positive number is greater than a negative number. Instead, when comparing the <strong>strength or magnitude of skewness</strong>, we look at their <strong>absolute values</strong>.</p><p>For example:</p><p>|1.865034222864843| &gt; |-1.651094232142306|</p><p>So, the positive-skewed distribution has <strong>slightly stronger skewness</strong> than the negative-skewed distribution.</p><p>The important thing to remember is:</p><p><strong>Sign → Direction of skewness</strong></p><p><strong>Absolute value → Magnitude or strength of skewness</strong></p><h4>5. Kurtosis: It’s About Tails, Not Peaks</h4><h4>5.1 What Kurtosis Really Measures</h4><p>While going through many sites and researching about <strong>Kurtosis</strong>, I got to know that people usually describe it as the <strong>“peakedness”</strong> of a distribution.</p><p>But is it really so?</p><p><strong>Not exactly.</strong></p><p><strong>Kurtosis</strong> is a <strong>standardized fourth central moment</strong> that is particularly <strong>sensitive to extreme observations and tail behaviour.</strong></p><p>In simple words, it helps us understand the <strong>relative importance of extreme observations and tail behaviour.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*AXj6m63PM-2HU_UCiIy1gw.png" /></figure><p>In the above image, can you focus on the different patterns of the <strong>tails</strong>?</p><p>Yes, these differences in tail behaviour are related to <strong>Kurtosis.</strong></p><p>As we learned earlier in this blog while understanding the formulation of <strong>Skewness</strong>, a similar pattern applies to <strong>Kurtosis</strong> as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*-vScEgU5-MXnJqHK2tGlWw.png" /></figure><p>which on expanding will give us:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*0yytVJ-k2VZj7gFeDKo1YQ.png" /></figure><p>Here, we simply take the <strong>Fourth Central Moment</strong> and, to standardize it, divide it by the <strong>fourth power of the Standard Deviation</strong>.</p><p>Here is a simple flowchart to help us remember it effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*z_5Lz_A0JWn-Wx6mqIdCAw.png" /></figure><p>But as we know, this formulation is for <strong>Population</strong> data, and we usually do not have access to the entire population. So, we need a <strong>Sample</strong> formula to apply.</p><p>But before getting there, I want us to learn one more important concept, <strong>Excess Kurtosis</strong>.</p><h4>5.2 Why the Fourth Power?</h4><p>Before going further, another question may arise here:</p><p><strong>Why the 4th power?</strong></p><p>As we wanted to know the <strong>direction</strong> in Skewness, we used the <strong>3rd power</strong>, which preserves the sign of the deviation.</p><p>But here, we want deviations on both sides of the mean to contribute positively, while also giving much greater weight to large deviations. The <strong>4th power</strong> does exactly that.</p><p>For example:</p><p>(-2)⁴ = 16</p><p>and</p><p>(2)⁴ = 16</p><p>So, both positive and negative deviations contribute positively.</p><p>But that’s not the only reason we use the 4th power.</p><p>The fourth power also gives <strong>extreme values a disproportionately large weight</strong>.</p><p>For example:</p><p>10⁴ = 10,000</p><p>This means that as an observation gets farther away from the mean, its contribution to the Fourth Central Moment increases very rapidly.</p><p>So, <strong>Kurtosis doesn’t just care that an observation is far away, the fourth power makes it care much more as the observation gets farther away.</strong></p><h4>5.3 Excess Kurtosis: Where Does the “3” Come From?</h4><p>Now, let’s move towards <strong>Excess Kurtosis</strong>.</p><p>To understand Excess Kurtosis, we first need to look at the different values of <strong>Kurtosis</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*4bCF-kMhlZYwkCM05tHBaw.png" /></figure><p>And to understand where this <strong>3</strong> came from, we must know a little more about the <strong>Normal Distribution</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/146/1*xOwneuBx4kOHZxgGidM7kw.png" /></figure><p>This is the <strong>Standard Normal Random Variable</strong>, which is obtained when we take any point (X) from a normal distribution, subtract the mean, and divide it by the <strong>standard deviation</strong>:</p><p>This transformation is called <strong>standardization</strong>.</p><p>It becomes a special case of the Normal Distribution when the mean is (0) and the standard deviation is (1) i.e</p><p>Z ~ N(0,1)</p><p>So, for the <strong>Standard Normal Distribution</strong>, the mean is (0) and the standard deviation is (1).</p><p>Now, for <strong>Kurtosis</strong>, we are interested in the Fourth Central Moment:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*cZlE8M_vzTQMCMwpDeZ_xg.png" /></figure><p>For a Standard Normal Random Variable, the even moments follow a very interesting pattern:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/166/1*8jRIVievBmKxIgdddMhXEg.png" /></figure><p>For k = 2, we are dealing with the <strong>Fourth Moment</strong>.</p><p>Here, !! represents the <strong>Double Factorial</strong>, which means we multiply every other number as we move downward:</p><p>3!! = 3 × 1 = 3</p><p>And that’s where our famous <strong>3</strong> comes from!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*6d6ktMig4MG0ziZZR2d9GQ.png" /></figure><p>So, we can say that the <strong>kurtosis of a Normal Distribution is 3.</strong></p><p>That’s why we use <strong>3 as the baseline</strong> when interpreting Kurtosis.</p><p>However, the raw Kurtosis values are not always very intuitive to interpret. For example, saying that a distribution has a Kurtosis of (5) doesn’t immediately tell us much.</p><p>So, we make the interpretation easier by subtracting the Normal Distribution’s Kurtosis, which is (3).</p><p>Therefore:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/1*deEQgJnZGfv-nMZULBmB6Q.png" /></figure><p>Now the interpretation becomes much simpler:</p><p>- <strong>Excess Kurtosis (&gt; 0)</strong> → generally indicates heavier tails and greater sensitivity to extreme observations than the Normal Distribution</p><p>- <strong>Excess Kurtosis (= 0)</strong> → same kurtosis as the Normal Distribution</p><ul><li><strong>Excess Kurtosis (&lt; 0)</strong> → generally indicates lighter tails and less sensitivity to extreme observations than the Normal Distribution</li></ul><h4>5.4 Leptokurtic, Mesokurtic and Platykurtic Distributions</h4><p>Let us see this through graphs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*ufhrbA_tVVEmCfRm41NmJA.png" /></figure><p>As we can clearly see in the above graph, the value of <strong>Excess Kurtosis = 20.52</strong>, which is very high compared to 0.</p><p>This indicates that the distribution has <strong>higher kurtosis and typically heavier tails, with greater sensitivity to extreme observations than a Normal Distribution</strong>. Such a distribution is commonly referred to as <strong>Leptokurtic</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*sPkfde4rqLPZoErRAGiirw.png" /></figure><p>Here, the <strong>Excess Kurtosis = -0.01</strong>, which is very close to 0.</p><p>This tells us that the distribution has approximately the same kurtosis as a Normal Distribution, so we can consider it approximately <strong>Mesokurtic</strong>. However, this does not mean that the distribution is necessarily normally distributed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*UUqBSEqUCN_7lPrb4IsXzg.png" /></figure><p>Here, the <strong>Excess Kurtosis = -1.18</strong>.</p><p>Since the excess kurtosis is <em>negative</em>, the distribution has lower kurtosis than a <em>Normal Distribution</em> and typically less influence from extreme observations. Such a distribution is commonly referred to as <strong>Platykurtic</strong>.</p><p>As you can see, these differences in the tails are also quite evident from the graphs themselves.</p><p>Here is the Python code used to generate the above graphs:</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from scipy.stats import kurtosis, gaussian_kde<br><br>np.random.seed(42)<br><br># 1. Heavy-tailed distribution<br>heavy = np.random.standard_t(df=3, size=10000)<br><br># 2. Normal distribution<br>normal = np.random.normal(loc=0, scale=1, size=10000)<br><br># 3. Light-tailed distribution<br>light = np.random.uniform(-2, 2, size=10000)<br><br><br># Calculate excess kurtosis<br>print(&quot;Heavy-tail kurtosis:&quot;, kurtosis(heavy))<br>print(&quot;Normal kurtosis:&quot;, kurtosis(normal))<br>print(&quot;Light-tail kurtosis:&quot;, kurtosis(light))<br><br><br># -------------------------<br># Heavy-tailed distribution<br># -------------------------<br>plt.figure(figsize=(8, 5))<br><br>plt.hist(heavy, bins=100, density=True, alpha=0.6)<br><br># KDE<br>x = np.linspace(-10, 10, 1000)<br>kde = gaussian_kde(heavy)<br>plt.plot(x, kde(x), linewidth=2)<br><br>plt.title(f&quot;Heavy-Tailed Distribution\nExcess Kurtosis = {kurtosis(heavy):.2f}&quot;)<br>plt.xlabel(&quot;Value&quot;)<br>plt.ylabel(&quot;Density&quot;)<br>plt.show()<br><br><br># -------------------------<br># Normal distribution<br># -------------------------<br>plt.figure(figsize=(8, 5))<br><br>plt.hist(normal, bins=50, density=True, alpha=0.6)<br><br># KDE<br>x = np.linspace(-4, 4, 1000)<br>kde = gaussian_kde(normal)<br>plt.plot(x, kde(x), linewidth=2)<br><br>plt.title(f&quot;Normal Distribution\nExcess Kurtosis = {kurtosis(normal):.2f}&quot;)<br>plt.xlabel(&quot;Value&quot;)<br>plt.ylabel(&quot;Density&quot;)<br>plt.show()<br><br><br># -------------------------<br># Light-tailed distribution<br># -------------------------<br>plt.figure(figsize=(8, 5))<br><br>plt.hist(light, bins=50, density=True, alpha=0.6)<br><br># KDE<br>x = np.linspace(-2.5, 2.5, 1000)<br>kde = gaussian_kde(light)<br>plt.plot(x, kde(x), linewidth=2)<br><br>plt.title(f&quot;Light-Tailed Distribution\nExcess Kurtosis = {kurtosis(light):.2f}&quot;)<br>plt.xlabel(&quot;Value&quot;)<br>plt.ylabel(&quot;Density&quot;)<br>plt.show()</pre><p>By default, SciPy’s kurtosis() function returns Fisher’s excess kurtosis, where the Normal Distribution has a value of 0.</p><h4>5.5 Sample Kurtosis and Fisher’s Correction</h4><p>Now, as we are clear about <strong>Excess Kurtosis</strong>, we are actually one step closer to our <strong>Sample Data</strong> formula for Kurtosis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*ri8oOYAFpLtTbLJUPNDEHQ.png" /></figure><p>Here, (g_2) represents the <strong>sample excess kurtosis</strong>.</p><p>As we learned earlier, we obtain <strong>excess kurtosis</strong> by dividing the Fourth Central Moment by the square of the Second Central Moment and then subtracting 3, the kurtosis of a <strong>Normal Distribution.</strong></p><p>But just like we saw with Skewness, this estimator has a <strong>small-sample bias</strong>.</p><p>Therefore, we apply a correction to obtain the <strong>Bias-Corrected Sample Excess Kurtosis</strong>, also known as <strong>Fisher’s correction</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*KEAe0G3vrUoZEgEk7E4CEQ.png" /></figure><p>This is the <strong>Bias-Corrected Sample Excess Kurtosis (Fisher’s correction).</strong></p><p>One last important thing to keep in mind before we move on.</p><p>As I mentioned before, people often associate <strong>Kurtosis</strong> with <strong>peakedness</strong>. But this is not always true and should not be the centre of its definition.</p><p><strong>Two distributions can have similar peaks but very different tail behaviour.</strong></p><p>Therefore:</p><p>Kurtosis is strongly related to tail behaviour and the influence of extreme observations, rather than simply being a measure of peak height.</p><h4>5.6 Skewness vs. Kurtosis: The Memory Map</h4><p>And with that, I will end this section with a <strong>Memory Map </strong>for you all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*I4LozJxvKK3A4x5J9XraUQ.png" /></figure><blockquote><strong>A subtle but VERY important point</strong></blockquote><p>A distribution can have <strong>High Skewness</strong> but <strong>Low Kurtosis</strong>, or <strong>Low Skewness</strong> but <strong>High Kurtosis</strong>.</p><p>Why?</p><p>Because <strong>Skewness and Kurtosis measure two different aspects of a distribution</strong>:</p><p>- <strong>Skewness</strong> → tells us about the <strong>asymmetry and direction</strong> of the distribution.</p><p>- <strong>Kurtosis</strong> → tells us about the <strong>behaviour of extreme values and the tails</strong>.</p><p>So, a distribution can be almost perfectly symmetric while still having very heavy or very light tails.</p><p>A key thing to remember is that <strong>symmetry does not tell us anything about the behaviour of extreme values</strong>.</p><h4>6. Calculating Skewness and Kurtosis in Python</h4><p>I have provided the Python codes above, but once again, I’ll give you the functions we can use to calculate <strong>Skewness</strong> and <strong>Kurtosis</strong>.</p><pre>import pandas as pd<br><br>df[&quot;variable&quot;].skew()<br>df[&quot;variable&quot;].kurt()</pre><p>The pandas kurt() function returns Fisher’s sample excess kurtosis with a bias correction by default.</p><pre>from scipy.stats import skew, kurtosis<br><br>skew(df[&quot;variable&quot;])<br>kurtosis(df[&quot;variable&quot;])</pre><p>By default, SciPy’s skew() calculates the biased sample skewness, while kurtosis() returns the biased Fisher excess kurtosis unless the corresponding bias correction options are changed.</p><h4>7. Taming Skewness: Data Transformations</h4><p>Can we judge whether our data is <strong>good or bad</strong> just by looking at the value of <strong>Skewness</strong>?</p><p>Before coming to any conclusion, we must first ask,</p><p><strong>Is the skewness genuine? Is it caused by extreme values or outliers? Does it actually affect our analysis or the ML algorithm we are going to use? Or could a transformation help?</strong></p><p><strong>Skewness itself is not necessarily a problem.</strong> Its importance depends on the nature of the data, the purpose of the analysis, and the <strong>ML algorithm</strong> being used.</p><p>As I mentioned above, we can apply different <strong>Transformations</strong> to reduce skewness. Now, let’s discuss them one by one.</p><h4><strong>7.1. Log Transformation</strong></h4><p>As the name itself suggests, we take the <strong>logarithm of the values</strong>.</p><p>A log transformation compresses large values more strongly than smaller values, which can significantly reduce <strong>strong right skewness</strong>.</p><p>Why not usually for <strong>Left Skewness</strong>?</p><p>The standard logarithm is defined only for <em>positive values</em>, so we cannot directly apply it to data containing zero or negative values.</p><p>For left-skewed data, we may need to consider a different transformation, depending on the nature of the data.</p><h4><strong>7.2. Square Root Transformation</strong></h4><p>Again, as the name suggests, we take the <strong>square root of the values</strong>.</p><p>It compresses larger values, but less aggressively than a logarithmic transformation, so it can be useful for <strong>moderate right skewness</strong>.</p><p>However, like the ordinary square-root function, it requires non-negative values.</p><h4><strong>7.3. Cube Root Transformation</strong></h4><p>Here, we take the <strong>cube root of the values</strong>.</p><p>One useful property of the cube root is that it can be applied to <strong>negative as well as positive values</strong>.</p><p>Therefore, it can be useful for reducing both <strong>right and left skewness</strong>, depending on the data.</p><h4><strong>7.4. Box-Cox Transformation</strong></h4><p>The <strong>Box-Cox Transformation</strong> is named after the two statisticians who introduced the method, <strong>George Box</strong> and <strong>David Cox</strong>.</p><p>It is a statistical technique that searches for a suitable value of ( λ ) to transform the data, often with the goal of making the distribution more symmetric or improving the assumptions of a statistical model.</p><p>The transformation is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/265/1*Z0GVaTlS6c5zhLzRW9RAAw.png" /></figure><p>If:</p><p>λ = 0</p><p>Box–Cox transformation corresponds to a <strong>logarithmic transformation.</strong></p><p>For:</p><p>λ ≠ 0</p><p>the corresponding power transformation is applied.</p><p>One important limitation to remember is that the standard <strong>Box-Cox transformation requires strictly positive data</strong>.</p><p>Here is a Python example showing how these transformations work:</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from scipy.stats import boxcox<br>import seaborn as sns<br><br># Skewed positive data<br>X = np.array([<br>    10, 12, 15, 18, 20, 25,<br>    30, 40, 60, 100, 150, 300<br>])<br><br># Apply Box-Cox transformation<br>X_boxcox, lambda_boxcox = boxcox(X)<br><br>print(&quot;Box-Cox lambda:&quot;, lambda_boxcox)<br><br># Create plots<br>plt.figure(figsize=(12, 5))<br><br># Original data<br>plt.subplot(1, 2, 1)<br>sns.histplot(X, kde=True, bins=8, stat=&quot;density&quot;)<br>plt.title(&quot;Original Data&quot;)<br>plt.xlabel(&quot;Value&quot;)<br>plt.ylabel(&quot;Density&quot;)<br><br># Box-Cox transformed data<br>plt.subplot(1, 2, 2)<br>sns.histplot(X_boxcox, kde=True, bins=8, stat=&quot;density&quot;)<br>plt.title(f&quot;Box-Cox Transformed (λ = {lambda_boxcox:.2f})&quot;)<br>plt.xlabel(&quot;Transformed Value&quot;)<br>plt.ylabel(&quot;Density&quot;)<br><br>plt.tight_layout()<br>plt.show()</pre><p><em>Box-Cox </em>λ <em>: -0.3978727501273978</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MFBe_wpLI3nebeuhzo3AoQ.png" /></figure><h4><strong>7.5. Yeo-Johnson Transformation</strong></h4><p>The <strong>Yeo-Johnson Transformation</strong> is named after the researchers <strong>In-Kwon Yeo</strong> and <strong>Richard A. Johnson</strong>, who introduced the method in 2000.</p><p>The <strong>Yeo–Johnson transformation</strong> is similar in purpose to the <strong>Box–Cox transformation</strong>, but it can handle zero and negative values i.e</p><p>X &gt; 0 , X = 0 , X &lt; 0</p><p>So, unlike Box-Cox, the Yeo-Johnson Transformation can be applied to data containing <strong>positive, zero, and negative values</strong>.</p><p>The goal remains similar, to find a suitable transformation that can reduce skewness and make the distribution more symmetric.</p><p>Here is the Python code example for you:</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from scipy.stats import yeojohnson<br>import seaborn as sns<br><br># Data containing negative, zero and positive values<br>X = np.array([<br>    -100, -50, -30, -20, -10,<br>    -5, 0, 2, 5, 10, 20, 50, 100, 200<br>])<br><br># Apply Yeo-Johnson<br>X_yeojohnson, lambda_yeojohnson = yeojohnson(X)<br><br>print(&quot;Yeo-Johnson lambda:&quot;, lambda_yeojohnson)<br><br># Create plots<br>plt.figure(figsize=(12, 5))<br><br># Original data<br>plt.subplot(1, 2, 1)<br>sns.histplot(X, kde=True, bins=8)<br>plt.title(&quot;Original Data&quot;)<br>plt.xlabel(&quot;Value&quot;)<br>plt.ylabel(&quot;Density&quot;)<br><br># Yeo-Johnson transformed data<br>plt.subplot(1, 2, 2)<br>sns.histplot(X_yeojohnson, kde=True, bins=8)<br>plt.title(f&quot;Yeo-Johnson Transformed (λ = {lambda_yeojohnson:.2f})&quot;)<br>plt.xlabel(&quot;Transformed Value&quot;)<br>plt.ylabel(&quot;Density&quot;)<br><br>plt.tight_layout()<br>plt.show()</pre><p><em>Yeo-Johnson </em>λ <em>: 0.9090980955368206</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*souPLjzeH4Wa3qCfwSeagg.png" /></figure><h4>8. Standardization vs. Transformation</h4><p>One must have complete clarity about two things here:</p><p><strong>Standardization vs Skewness </strong>and <strong>Standardization vs Transformation</strong></p><h4><strong>Standardization</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/146/1*xOwneuBx4kOHZxgGidM7kw.png" /></figure><p><strong>Standardization</strong> transforms the data so that its <strong>mean</strong> becomes 0 and its <strong>standard deviation</strong> becomes 1.</p><p>Why?</p><p>Because <strong>standardization changes the location and scale</strong> of the data but does not change the distribution’s shape in the sense relevant to measures such as <strong>skewness and kurtosis</strong>.</p><p>On the other hand,</p><p><strong>Transformation</strong> can change the <strong>shape of the distribution</strong> and potentially reduce skewness.</p><p>So, remember:</p><p><strong>Standardization changes the scale. Transformation can change the shape.</strong></p><h4>9. Kurtosis in Machine Learning</h4><p>Now that we understand the mathematics behind <strong>Kurtosis</strong>, an important question remains: <strong>How can it be useful in Machine Learning?</strong></p><p>Kurtosis can help us investigate the influence of <strong>extreme observations and tail behaviour relative to a normal distribution.</strong></p><p>If we observe high kurtosis, it gives us a reason to investigate further.</p><p>We can look for:</p><p>- <strong>Outliers</strong></p><p>- <strong>Data quality issues</strong></p><p>- <strong>Genuine extreme observations</strong></p><p>But remember:</p><p><strong>High Kurtosis does not automatically mean that we should remove the extreme values.</strong></p><p>An extreme observation could be a genuine and important part of the data. Removing it without understanding its origin can actually damage our analysis.</p><h4>10. A Practical EDA Workflow</h4><p>For a numerical feature, we can examine -&gt;</p><p>- <strong>Mean</strong></p><p>- <strong>Median</strong></p><p>- <strong>Standard Deviation</strong></p><p>- <strong>Skewness</strong></p><p>- <strong>Kurtosis</strong></p><p>Then, through visualizations such as -&gt;</p><p>- <strong>Histogram</strong></p><p>- <strong>Boxplot</strong></p><p>- <strong>KDE Plot</strong></p><p>- <strong>Q-Q Plot</strong></p><p>we can better understand the distribution of our data.</p><p>Together, these statistical summaries and visualizations form an important part of <strong>Exploratory Data Analysis (EDA)</strong>.</p><p>And with that, I will end this blog with a <strong>Flowchart for EDA</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*O9D4yckS-RNpmfsyN933qg.png" /></figure><h4>12. Supporting Materials</h4><p>If you’d like to go beyond this article, everything used here is available for you to explore:</p><ul><li>📂 <a href="https://github.com/MansiBramta/skewness-kurtosis"><strong>GitHub Repository</strong></a>: the full article in markdown, along with all the figures, diagrams, and visualizations used in this post.</li><li>📊 <a href="https://www.kaggle.com/code/mansibramta/skewness-kurtosis"><strong>Interactive Kaggle Notebook</strong></a>: run the Python code yourself and experiment with skewness, kurtosis, and the transformations.</li><li>📖 <a href="https://towardsdatascience.com/skewness-and-kurtosis-from-moments-to-machine-learning/"><strong>Original article on Towards Data Science</strong></a>: this article was first published on Towards Data Science.</li></ul><p>If you found this helpful, feel free to clap 👏, leave a comment, or share it with someone learning statistics or data science. I’d love to hear your thoughts and questions!</p><p>You can also connect with me on <a href="https://www.linkedin.com/in/mansi-bramta-65358741b"><strong>LinkedIn</strong></a>.</p><p><em>Happy learning!</em></p><h4><strong>12. Resources</strong></h4><ol><li><strong>SciPy Documentation — Statistical Functions</strong><br>Used for the implementation and behaviour of functions such as skew(), kurtosis(), boxcox(), and yeojohnson().</li><li><strong>SciPy Documentation — </strong><strong>scipy.stats.skew</strong><br>Reference for calculating sample skewness and understanding the bias parameter.</li><li><strong>SciPy Documentation — </strong><strong>scipy.stats.kurtosis</strong><br>Reference for Fisher&#39;s excess kurtosis and the bias-correction options.</li><li><strong>SciPy Documentation — </strong><strong>scipy.stats.boxcox</strong><br>Reference for the Box–Cox transformation and its implementation.</li><li><strong>SciPy Documentation — </strong><strong>scipy.stats.yeojohnson</strong><br>Reference for the Yeo–Johnson transformation and its implementation.</li><li><strong>Pandas Documentation — Descriptive Statistics</strong><br>Reference for .skew() and .kurt() used in the practical examples.</li><li><strong>NIST/SEMATECH e-Handbook of Statistical Methods</strong><br>Reference for statistical concepts including moments, skewness, kurtosis, distributions, and exploratory data analysis.</li><li><strong>George E. P. Box &amp; David R. Cox (1964)</strong><br><em>An Analysis of Transformations.</em><br><strong>Journal of the Royal Statistical Society: Series B</strong>, 26(2), 211–252.<br> — Original paper introducing the Box–Cox transformation.</li><li><strong>In-Kwon Yeo &amp; Richard A. Johnson (2000)</strong><br><em>A New Family of Power Transformations to Improve Normality or Symmetry.</em><br><strong>Biometrika</strong>, 87(4), 954–959.<br> — Original paper introducing the Yeo–Johnson transformation.</li><li><strong>Joanes, D. N. &amp; Gill, C. A. (1998)</strong><br><em>Comparing Measures of Sample Skewness and Kurtosis.</em><br><strong>Journal of the Royal Statistical Society: Series D (The Statistician)</strong>, 47(1), 183–189.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7964a9170043" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Confidence Intervals: The Art of Being Honestly Uncertain]]></title>
            <link>https://medium.com/@mansibramta12/confidence-intervals-the-art-of-being-honestly-uncertain-26f013073f9c?source=rss-4e5a6b578be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/26f013073f9c</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[mathematics]]></category>
            <dc:creator><![CDATA[Mansi Bramta]]></dc:creator>
            <pubDate>Thu, 08 Oct 2026 09:51:33 GMT</pubDate>
            <atom:updated>2026-10-08T09:51:33.077Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uELR7Fok0BvlPmitCD4cNg.png" /></figure><h4><strong>Margin of error, critical values, and a common misunderstanding</strong></h4><p>We ended our previous blog on a very unconventional discussion, which made no sense right?</p><p>To leave you with that till this blog was a gig. In this blog we will be talking about something very important in our “Statistical Journey”.</p><h3>Confidence Interval</h3><p>I bet that this name is not unknown to you. I was also once very unclear about this topic till I took the challenge to learn it to the depth in the form of a story, why and how?</p><p>We discussed earlier right? why there was a need of “sampling data” and how it told us about our “population data”.</p><p>We took a sample and calculated its mean but the question here was how close it was to the true population mean. This somehow created a need of interval.</p><p>In the example, our very first sample mean came:</p><pre>X̄ = ₹213,333</pre><p>which is a <strong>Point Estimate</strong> but what if we can express in the form of <strong>Interval Estimate</strong> (for illustration) i.e</p><pre>₹150000 &lt; μ &lt; ₹300000</pre><p>and these values are not random they are calculated from the repeated sample mean observations and is known as <strong>Confidence Interval</strong>. So a formal definition would be:</p><blockquote>A confidence interval gives us a range of values constructed from sample data that is designed to capture the unknown population parameter with a certain level of confidence.</blockquote><p>If we think it is basically:</p><pre>Estimate ± Margin of Error</pre><p>What is this “Margin of Error”?</p><p>The margin of error tells us how far we move away from our point estimate to create the interval.</p><p>Remember from our sampling distribution article:</p><p>When we take repeated samples, the sample means vary.</p><p>That variation is measured using the Standard Error.</p><p>For a population mean:</p><pre>SE = σ / √n</pre><p>So if we know the standard error, we have an idea of how much our sample mean can vary from sample to sample.</p><p>But we also need to decide how much of that variation we want to cover.</p><p>That’s where the <strong>critical value</strong> comes in. We will discuss about this later on.</p><p>Therefore:</p><pre>Margin of Error = Critical Value × Standard Error</pre><p>And therefore:</p><pre>Confidence Interval = Estimate ± (Critical Value × SE)</pre><p>You’ll commonly see:</p><ul><li>90% confidence</li><li>95% confidence</li><li>99% confidence</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*dyaygRNEy3EOTq18FRECMw.jpeg" /></figure><p>95% or so does NOT mean that there is a 95% probability that the particular interval you calculated contains μ.</p><p>Confidence level tells us how much of the sampling distribution we want our interval-building procedure to capture.</p><p>For 95% confidence interval we get critical value of 1.96, which becomes</p><pre>x̄ ± 1.96 × SE</pre><p>but why 1.96? How did this value come about?</p><p>For a <strong>standard normal distribution</strong>:</p><pre>Z ~ N(0, 1)</pre><p>It is centered at 0. The total area under the curve represents 100% of the probability.</p><p>We want a 95% confidence level.</p><p>So we want to capture 95% of the area in the middle of the distribution.</p><p>That leaves:</p><pre>100% − 95% = 5%</pre><p>outside.</p><p>Because the normal distribution is symmetric, we split that 5% equally between the two tails.</p><p>So:</p><pre>5% / 2 = 2.5%</pre><p>Therefore 2.5% on each side.</p><pre>2.5% + 95% + 2.5% = 100%</pre><p>now we ask:</p><p>“What Z-score has 97.5% of the distribution to its left?”</p><p>How 97.5%?</p><pre>95% + 2.5% = 97.5%</pre><p>So the Z-score which gives 97.5% to its left gives 1.96.</p><p>The distribution is symmetric so for the right side it remains same just the change in direction giving −1.96.</p><p>Therefore:</p><pre>P(−1.96 &lt; Z &lt; 1.96) = 95%</pre><p>Similarly:</p><pre>P(−1.645 &lt; Z &lt; 1.645) ≈ 90%<br>P(−2.576 &lt; Z &lt; 2.576) ≈ 99%</pre><p>please refer to the z-table from below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*h-Ww9SEpcbWhRgEDIxEvoQ.png" /></figure><p>Did you notice something above?</p><pre>90% → z ≈ 1.645<br>95% → z ≈ 1.96<br>99% → z ≈ 2.576</pre><p>as the confidence is increasing the value of z is also increasing, but shouldn’t it be the inverse? We want to be more confident, so why are we paying for it with a larger z?</p><p>But it doesn’t work like that.</p><p>Suppose you’re trying to catch a ball.</p><p>If you want to be reasonably sure you’ll catch it, you can stand in a small area.</p><p>But if you want to be almost certain, you need to make the area larger.</p><p>Same idea here.</p><p>Higher z means larger margin of error.</p><p>Therefore:</p><pre>Higher confidence → wider CI</pre><p>Let’s use it once:</p><p>Suppose:</p><pre>x̄ = 100</pre><p>and:</p><pre>SE = 5</pre><p>We want a 95% confidence interval.</p><p>For 95% confidence:</p><pre>z = 1.96</pre><p>First calculate the margin of error:</p><pre>ME = 1.96 × 5<br>ME = 9.8</pre><p>Then:</p><pre>CI = 100 ± 9.8</pre><p>Therefore:</p><pre>(90.2, 109.8)</pre><p>So our confidence interval is:</p><pre>90.2 &lt; μ &lt; 109.8</pre><p>Do you remember in previous blog how with an example i showed you the effect of n on <strong>standard error</strong>. How increasing n can narrow down our curve therefore we can connect it directly here that increasing the value of n will give us a narrower interval.</p><p>Therefore:</p><pre>Larger sample → smaller SE → smaller margin of error → narrower CI</pre><p>Concluding this with what actually 95% confidence interval mean:</p><blockquote>“A 95% confidence level means that if we repeatedly took samples and constructed confidence intervals using the same method, about 95% of those intervals would contain the true population parameter.”</blockquote><p>Here we are dealing with a population mean which is unknown but somehow if we know the population standard deviation (σ) we get:</p><pre>x̄ ± z(α/2) × σ / √n</pre><p>The z-score we have been talking about, but what if the population standard deviation is unknown too, and that is a very realistic case, we move with <strong>t-distribution</strong>:</p><pre>x̄ ± t(α/2, n−1) × s / √n</pre><p>We will be talking about this in the further section.</p><p>There is one more important term we should learn, that is <strong>Prediction Interval</strong>.</p><p>Suppose we want to estimate the average salary of employees.</p><blockquote>That’s a population parameter → confidence interval.</blockquote><p>But suppose we want to predict the salary of one new employee.</p><blockquote>That’s a different problem → prediction interval.</blockquote><blockquote>“Prediction intervals are generally wider because an individual observation has more variability than the estimated population mean.”</blockquote><p>Now let’s connect this to <strong>Data Science</strong>. Why is it so important? While figuring out the data you got a point estimation and then the confidence interval that tells you how uncertain your point estimate is.</p><p>We already know how to calculate confidence interval but let us see it using scipy in python:</p><pre>import scipy.stats as stats<br><br>sample_mean = 52<br>population_std = 10<br>sample_size = 100<br>confidence_level = 0.95<br># Standard Error<br>standard_error = population_std / (sample_size ** 0.5)<br># Calculate confidence interval<br>confidence_interval = stats.norm.interval(<br>    confidence_level,<br>    loc=sample_mean,<br>    scale=standard_error<br>)<br>print(&quot;95% Confidence Interval:&quot;, confidence_interval)</pre><pre>95% Confidence Interval: (50.04, 53.96)</pre><pre>import matplotlib.pyplot as plt<br><br>sample_mean = 52<br>lower = 50.04<br>upper = 53.96<br>true_mean = 50<br>plt.figure(figsize=(10, 2))<br># Confidence interval<br>plt.plot([lower, upper], [0, 0], linewidth=5)<br># Sample mean<br>plt.scatter(sample_mean, 0, s=100, label=&quot;Sample Mean&quot;)<br># True population mean<br>plt.axvline(true_mean, linestyle=&quot;--&quot;, label=&quot;True Population Mean&quot;)<br>plt.xlim(47, 57)<br>plt.yticks([])<br>plt.xlabel(&quot;Mean&quot;)<br>plt.title(&quot;95% Confidence Interval&quot;)<br>plt.legend()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*HgqUr_og0mDMtyBsZ3Sy3A.png" /></figure><p>Here the population mean is 50, but our one sample gave a mean of 52. Notice that this interval (50.04, 53.96) just misses the true mean. This is one of the roughly 5% of intervals that fail.</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br># Population parameters<br>population_mean = 50<br>population_std = 10<br># Simulation settings<br>sample_size = 30<br>num_intervals = 100<br>confidence_level = 0.95<br># Critical value for 95% CI<br>critical_value = 1.96<br># Store intervals<br>intervals = []<br>np.random.seed(42)<br>for i in range(num_intervals):<br>    # Take a random sample from the population<br>    sample = np.random.normal(<br>        population_mean,<br>        population_std,<br>        sample_size<br>    )<br>    # Sample mean<br>    sample_mean = np.mean(sample)<br>    # Standard Error<br>    standard_error = population_std / np.sqrt(sample_size)<br>    # Margin of Error<br>    margin_of_error = critical_value * standard_error<br>    # Confidence interval<br>    lower = sample_mean - margin_of_error<br>    upper = sample_mean + margin_of_error<br>    # Does the interval contain the true population mean?<br>    contains_true_mean = lower &lt;= population_mean &lt;= upper<br>    intervals.append(<br>        (lower, upper, sample_mean, contains_true_mean)<br>    )</pre><pre>plt.figure(figsize=(10, 12))<br><br>for i, (lower, upper, sample_mean, contains_true_mean) in enumerate(intervals):<br>    if contains_true_mean:<br>        color = &quot;green&quot;<br>    else:<br>        color = &quot;red&quot;<br>    plt.plot(<br>        [lower, upper],<br>        [i, i],<br>        color=color,<br>        linewidth=2<br>    )<br>    plt.scatter(<br>        sample_mean,<br>        i,<br>        color=color,<br>        s=20<br>    )<br># True population mean<br>plt.axvline(<br>    population_mean,<br>    linestyle=&quot;--&quot;,<br>    linewidth=2,<br>    label=&quot;True Population Mean&quot;<br>)<br>plt.xlabel(&quot;Population Mean&quot;)<br>plt.ylabel(&quot;Sample&quot;)<br>plt.title(&quot;100 Simulated 95% Confidence Intervals&quot;)<br>plt.legend()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*3fUT9G3MTRXzx_eAz_K3NA.png" /></figure><p>On taking 100 random samples at 95% confidence interval the green lines are the ones including the population mean and the red ones are the ones which are not. We can see clearly 97 caught the true mean while 3 couldn’t which is consistent with the statement of a 95% confidence interval.</p><p>It does not mean “there’s a 95% chance the true mean is inside this particular interval.” The true mean is a fixed number, it’s either in your interval or it isn’t.</p><p>It means, if you repeated the process many times, about 95% of the intervals you build would contain the true mean.</p><p>Confidence intervals tell us where the population mean could be. Hypothesis testing helps us decide whether a specific claim about it is true or not. Let’s begin with the fundamentals in the next blog. Till then <strong>HAPPY LEARNING</strong>.</p><h3>Resources</h3><ul><li><a href="https://github.com/MansiBramta/Confidence_Interval"><strong>GitHub Repository</strong></a></li><li><a href="https://www.kaggle.com/code/mansibramta/confidence-intervals"><strong>Kaggle Notebook</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26f013073f9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can a Small Sample Really Speak for a Whole Population?]]></title>
            <link>https://medium.com/@mansibramta12/can-a-small-sample-really-speak-for-a-whole-population-668a53b3b548?source=rss-4e5a6b578be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/668a53b3b548</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[probability-distributions]]></category>
            <dc:creator><![CDATA[Mansi Bramta]]></dc:creator>
            <pubDate>Mon, 05 Oct 2026 13:18:12 GMT</pubDate>
            <atom:updated>2026-10-05T13:18:12.637Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1498uqOGE4UoOZqYTY9ikA.png" /></figure><h4>From population to sample to the normal distribution</h4><p>I have some 100–200 houses in my locality and I was curious to know what the average salary of a household is, so I thought of asking some. 100–200 is a large number to collect data from but 10–20 seems much more realistic, so I asked a few people and I came up with this data set:</p><blockquote>48333, 120833, 35000, 50833, 13333, 32500, 23333, 183333, 20000, 60000, 158333, 70833, 93333, 258333, 458333</blockquote><p>Of course, we have rich people here, average ones and below-average ones too, so the variance in the data is self-explanatory. But what if I really want to collect the same data for the whole area, can I do that? Yes, I can, but it will take time and too much work, right? But what if I want to do it for the state I am in, is it possible? Ahhhhhhh……..</p><p>That’s a task, isn’t it? It will consume a good amount of time and manpower. That’s the whole point. Sometimes it is very difficult to work with the population, it means collecting the data becomes an impossible task. Then what is the solution?</p><p>Solutions are often thought of at a small scale first. What if, rather than running for the <em>population mean</em>, we run for the <em>sample mean</em>? Or instead of observing the <em>population variance</em>, we go for the <em>sample variance</em>? Similarly, as I did for the average salary, I took a sample out of the population and I will look for the variables from it.</p><p>In many real-life scenarios we do it like this, mostly we do not have the population data, so by working with sample data we try to understand the population itself. Isn’t it confusing? How are the results supposed to match? How can this be true? But it is. We do not end up getting results exactly the same as our <em>population data</em>, but we can get closer to it.</p><blockquote><strong>Population Mean</strong> → μ</blockquote><blockquote><strong>Population Variance</strong> → σ²</blockquote><blockquote><strong>Sample Mean</strong> → X̄</blockquote><blockquote><strong>Sample Variance</strong> → s²</blockquote><p>Yes, we have different notations for population and sample just to make a proper distinction. And one must be well aware of these while working with the data. The important distinction here is that μ is called a <strong>parameter</strong> and X̄ is called a <strong>statistic</strong>.</p><p>So the data I collected above is my <strong>sample</strong>, and its mean is my <strong>X̄</strong>.</p><p>I hope this whole discussion above made one point very clear: <strong>why do we actually need sampling</strong>.</p><p>Above I told you that taking the data of the whole area is going to be a task, so it is better we work with the given 15 points. So what if I make these points my <strong>Population Data</strong>, and out of these I take 3 random data points and call it a <strong>Sample Data</strong>.</p><p>So μ = (48333 + 120833 + 35000 + 50833 + 13333 + 32500 + 23333 + 183333 + 20000 + 60000 + 158333 + 70833 + 93333 + 258333 + 458333)/15</p><p>μ = ₹108,444.20</p><p>and</p><p>σ² = 13,289,049,004.96</p><p>therefore:</p><p>Population Mean: ₹108,444.20</p><p>Population Variance: 13,289,049,004.96</p><p>Population Standard Deviation: ₹115,278.14</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br><br>data = [48333, 120833, 35000, 50833, 13333, 32500, 23333, 183333,<br>        20000, 60000, 158333, 70833, 93333, 258333, 458333]<br>mean = np.mean(data)<br>std = np.std(data, ddof=0)   # population std<br>fig, ax = plt.subplots(figsize=(10, 6))<br>sns.histplot(data, bins=8, stat=&quot;density&quot;, color=&quot;steelblue&quot;,<br>             edgecolor=&quot;black&quot;, alpha=0.6, ax=ax)<br>sns.kdeplot(data, color=&quot;crimson&quot;, linewidth=2, ax=ax)<br>ax.axvline(mean, color=&quot;green&quot;, linestyle=&quot;--&quot;, label=f&quot;Mean = ₹{mean:,.2f}&quot;)<br>ax.axvline(mean + std, color=&quot;orange&quot;, linestyle=&quot;:&quot;, label=f&quot;+1 SD = ₹{mean+std:,.2f}&quot;)<br>ax.axvline(mean - std, color=&quot;orange&quot;, linestyle=&quot;:&quot;, label=f&quot;-1 SD = ₹{mean-std:,.2f}&quot;)<br>ax.set_title(&quot;Population Data: Histogram with KDE&quot;)<br>ax.set_xlabel(&quot;Value (₹)&quot;)<br>ax.set_ylabel(&quot;Density&quot;)<br>ax.legend()<br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*dqmyyUmUta0LEP8qwlDgYg.png" /></figure><p>In the same way, if we take 158333, 23333, 458333 as my sample data, then</p><p>X̄ = (158333 + 23333 + 458333)/3</p><p>= ₹213333</p><p>and</p><p>s² = 49,575,000,000</p><p>therefore,</p><p>Sample mean = ₹213,333</p><p>Sample variance = 49,575,000,000</p><p>Sample standard deviation = ₹222,654.44</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br><br>sample = [158333, 23333, 458333]<br>mean = np.mean(sample)<br>std = np.std(sample, ddof=1)   # sample std (n-1)<br>fig, ax = plt.subplots(figsize=(10, 6))<br>sns.histplot(sample, bins=5, stat=&quot;density&quot;, color=&quot;mediumpurple&quot;,<br>             edgecolor=&quot;black&quot;, alpha=0.6, ax=ax)<br>sns.kdeplot(sample, color=&quot;crimson&quot;, linewidth=2, ax=ax, bw_adjust=1.5)<br>ax.axvline(mean, color=&quot;green&quot;, linestyle=&quot;--&quot;, label=f&quot;Mean = ₹{mean:,.2f}&quot;)<br>ax.axvline(mean + std, color=&quot;orange&quot;, linestyle=&quot;:&quot;, label=f&quot;+1 SD = ₹{mean+std:,.2f}&quot;)<br>ax.axvline(mean - std, color=&quot;orange&quot;, linestyle=&quot;:&quot;, label=f&quot;-1 SD = ₹{mean-std:,.2f}&quot;)<br>ax.set_title(&quot;Sample Data (n=3): Histogram with KDE&quot;)<br>ax.set_xlabel(&quot;Value (₹)&quot;)<br>ax.set_ylabel(&quot;Density&quot;)<br>ax.legend()<br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*eUUdtkKURQPXrz5FFrgACw.png" /></figure><p>Now, can you compare the two results side by side? Did you see the difference? Exactly, which brings us to our next point: why the <em>sample mean</em> is so different from the <em>population mean</em>. Taking one sample and working on it will not take us close to our population mean, this has to be done a number of times to get closer to the accuracy.</p><p>From our data, if we take 10 random samples of 3 points each:</p><blockquote>{48,333, 120,833, 35,000} → X̄₁ = 68,055.33</blockquote><blockquote>{50,833, 13,333, 32,500} → X̄₂ = 32,222.00</blockquote><blockquote>{183,333, 20,000, 60,000} → X̄₃ = 87,777.67</blockquote><blockquote>{70,833, 93,333, 258,333} → X̄₄ = 140,833.00</blockquote><blockquote>{458,333, 48,333, 13,333} → X̄₅ = 173,333.00</blockquote><blockquote>{120,833, 32,500, 183,333} → X̄₆ = 112,222.00</blockquote><blockquote>{35,000, 60,000, 93,333} → X̄₇ = 62,777.67</blockquote><blockquote>{158,333, 50,833, 20,000} → X̄₈ = 76,388.67</blockquote><blockquote>{23,333, 70,833, 258,333} → X̄₉ = 117,499.67</blockquote><blockquote>{13,333, 183,333, 93,333} → X̄₁₀ = 96,666.33</blockquote><p>We can clearly see that all the means are different from each other.</p><p>But what if we take mean of all these means?</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br><br>sample_means = [68055.33, 32222.00, 87777.67, 140833.00, 173333.00,<br>                112222.00, 62777.67, 76388.67, 117499.67, 96666.33]<br>pop_mean = 108444.20                      # population mean from your data<br>mean_of_means = np.mean(sample_means)     # ≈ 96,777.53<br>std_of_means = np.std(sample_means, ddof=1)<br>fig, ax = plt.subplots(figsize=(10, 6))<br>sns.histplot(sample_means, bins=6, stat=&quot;density&quot;, color=&quot;teal&quot;,<br>             edgecolor=&quot;black&quot;, alpha=0.6, ax=ax)<br>sns.kdeplot(sample_means, color=&quot;crimson&quot;, linewidth=2, ax=ax)<br>ax.axvline(mean_of_means, color=&quot;green&quot;, linestyle=&quot;--&quot;,<br>           label=f&quot;Mean of sample means = ₹{mean_of_means:,.2f}&quot;)<br>ax.axvline(pop_mean, color=&quot;navy&quot;, linestyle=&quot;-.&quot;,<br>           label=f&quot;Population mean = ₹{pop_mean:,.2f}&quot;)<br>ax.set_title(&quot;Distribution of 10 Sample Means (n = 3)&quot;)<br>ax.set_xlabel(&quot;Sample Mean (₹)&quot;)<br>ax.set_ylabel(&quot;Density&quot;)<br>ax.legend()<br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*t78pdZb8HUWl1jjsTWlz0Q.png" /></figure><p>Did you see how close it came to our population mean? And this is called the <strong>sampling distribution of the sample mean</strong>. Also, compare the original histogram to the one now, aren’t they completely different? The distribution of the population need not be <em>normal</em>, but as we repeatedly take samples and calculate their means, something interesting can happen.</p><p>With only 10 samples the histogram is still rough, but notice that the means are already bunching up around the population mean, much more tightly than the original values. As we take more samples and larger sample sizes, their distribution becomes increasingly close to a normal distribution under the conditions of the <strong>Central Limit Theorem</strong>.</p><p>If we plotted the population, we would be looking at the distribution of the individual values, on the other hand, for samples we are looking at “How are the possible sample means distributed?”</p><p>Now, I’ll tell you something you won’t believe until you see it yourself…</p><p><strong>“Expected Value of the Sample Mean (E(X̄)) = Population Mean (μ)”</strong></p><p>Yes, right, but in our graph above it is not, is it? That is because we only took 10 random samples, our <em>mean of sample means</em> came considerably close but not exactly equal to the <em>population mean</em>. So we have to take the average of the means of all possible samples to obtain the exact result.</p><p>You can notice above that the values of X̄₁, X̄₂, X̄₃, … are all different, neither <em>monotonically increasing</em> nor <em>monotonically decreasing</em>, this is due to how randomly we are choosing them. But when we consider all the possible samples, the lower and higher sample means balance around the population mean.</p><p>That’s why the sampling distribution is centered at μ and the sample mean is also called an <strong>unbiased estimator</strong> of the population mean. Unbiased doesn’t mean every estimate is correct, it means that if we repeatedly sampled and averaged the resulting sample means, the average would equal the true population mean.</p><p>Now, let us derive this:</p><p>Suppose our sample contains:</p><p>X₁, X₂, …, Xₙ</p><p>The sample mean is:</p><p>X̄ = (X₁ + X₂ + ⋯ + Xₙ)/n</p><p>Now take the expected value of both sides:</p><p>E(X̄) = E((X₁ + X₂ + ⋯ + Xₙ)/n)</p><p>Because (1/n) is a constant:</p><p>E(X̄) = (1/n) E(X₁ + X₂ + ⋯ + Xₙ)</p><p>Using the linearity of expectation:</p><p>E(X̄) = (1/n) [ E(X₁) + E(X₂) + ⋯ + E(Xₙ) ]</p><p>Each observation comes from the same population, so:</p><p>E(X₁) = E(X₂) = ⋯ = E(Xₙ) = μ</p><p>Therefore:</p><p>E(X̄) = (1/n)(μ + μ + ⋯ + μ)</p><p>There are (n) copies of (μ):</p><p>E(X̄) = nμ/n</p><p>So:</p><p>E(X̄) = μ</p><p>That’s the mathematical reason.</p><p>That was all about the <strong>Mean</strong>, but what about <strong>Variance</strong>? We already know how to measure the variance of each observation from the mean, but here we want to measure the variance of each <em>sample mean</em> from the <em>population mean</em>. The standard deviation of the sampling distribution of the sample mean is called the <strong>standard error of the mean</strong> and is denoted as:</p><p>SE(X̄) = σ/√n</p><p>It doesn’t mean:</p><p>“How many mistakes did we make?”</p><p>Instead, it measures the typical amount by which sample means vary from the population mean across repeated samples.</p><p>It is interesting to note that as we increase the sample size, the “standard error of the mean” decreases, that is very obvious from the formula above. So one must be very clear about the difference between <em>Standard Deviation</em> and <em>Standard Error</em>.</p><p>Here, σ/√n is the standard deviation of the sampling distribution of (X̄) when the observations are independent and identically distributed with finite variance.</p><p>In practice, (σ) is often unknown.</p><p>Then we estimate the standard error using the sample standard deviation (s):</p><p>SE(X̄) ≈ s/√n</p><p>Hold on to this for now, we will be discussing this more in further blogs.</p><p>Now, let’s see how we ended up here:</p><p>Suppose our sample contains:</p><p>X₁, X₂, …, Xₙ</p><p>The sample mean is:</p><p>X̄ = (X₁ + X₂ + ⋯ + Xₙ)/n</p><p>Therefore,</p><p>Var(X̄) = Var((X₁ + X₂ + ⋯ + Xₙ)/n)</p><p>= (1/n²) Var(X₁ + X₂ + ⋯ + Xₙ)</p><p>Since (X₁, X₂, …, Xₙ) are independent,</p><p>= (1/n²) [ Var(X₁) + Var(X₂) + ⋯ + Var(Xₙ) ]</p><p>Since each (Xᵢ) comes from the same population,</p><p>Var(Xᵢ) = σ²</p><p>therefore,</p><p>= (1/n²) [ σ² + σ² + ⋯ + σ² ]</p><p>= nσ²/n²</p><p>= σ²/n</p><p>Hence,</p><p>Var(X̄) = σ²/n</p><p>Taking the square root gives the standard deviation of the sampling distribution:</p><p>σ_X̄ = √(σ²/n)</p><p>σ_X̄ = σ/√n</p><p><em>Note: this formula assumes the observations are independent. In our small 15-point example we picked samples without replacement, so the actual spread of the sample means is slightly smaller than σ/√n (the correction is a factor of √((N−n)/(N−1)), called the finite population correction). For a large population, like a whole state, this difference is negligible, so we can safely use σ/√n.</em></p><p>Therefore, the <strong>standard error of the sample mean is</strong>:</p><p>SE(X̄) = σ/√n</p><p>Just a clear classification in case you got confused somewhere along the way:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*GFOyAmXNquh7AdT2a9K9Vw.png" /></figure><p>I said something above without validating it, so let us now see what effect it has if we increase n.</p><p>Let us first see from an example :</p><p>If μ = 50 and σ = 20</p><p>Let’s first take samples of:</p><p>n = 5</p><p>The standard error is:</p><p>SE = 20/√5</p><p>SE ≈ 8.94</p><p>Now suppose:</p><p>n = 30</p><p>Then:</p><p>SE = 20/√30</p><p>SE ≈ 3.65</p><p>Compare:</p><p>8.94 → 3.65</p><p>The standard error has decreased.</p><p>Now:</p><p>n = 100</p><p>Then:</p><p>SE = 20/√100</p><p>SE = 2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*J3e3E28vfTMWU1C3NZW9yw.png" /></figure><p>As we increase the value of nn (sample size), the <em>Standard Error keeps decreasing, and the sampling distribution becomes narrower.</em></p><p>This leads to one more conclusion: the original population might not be normally distributed, it can be right or left skewed, but as we increase the size of n to 30 or more (a common rule of thumb) the sampling distribution begins looking more regular and approximately bell-shaped, which is something explained by <strong>Central Limit Theorem (CLT)</strong>.</p><p>One thing to be clear about here: saying “as the sample size increases, the distribution becomes normal” is the wrong thing to say. What is actually true is that the population does not change.</p><p>If the population is skewed, it remains skewed.</p><p>What changes is the distribution of the sample means.</p><p>So,</p><blockquote><em>“As the sample size becomes sufficiently large, the sampling distribution of the sample mean approaches a normal distribution, under the conditions of the Central Limit Theorem.” Now we have finally reached the heart of the matter.</em></blockquote><h3>Central Limit Theorem (CLT)</h3><p><strong>“When we repeatedly take sufficiently large random samples from a population with a finite mean and variance, the sampling distribution of the sample mean becomes approximately normal, regardless of the original population’s shape.”</strong></p><p>If we write the normal distribution using mean and variance, then:</p><p>X̄ ≈ N(μ, σ²/n)</p><p>An example will help us more:</p><p>Since you have already studied the Exponential Distribution, let’s use it as our population. This is useful because an exponential distribution is clearly not normally distributed.</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br>np.random.seed(42)<br><br>population = np.random.exponential(scale=1, size=100000)<br><br>plt.figure(figsize=(8, 5))<br><br>plt.hist(population, bins=50, density=True)<br><br>plt.xlabel(&quot;Value&quot;)<br>plt.ylabel(&quot;Density&quot;)<br>plt.title(&quot;Original Population: Exponential Distribution&quot;)<br><br>plt.show()<br><br>print(&quot;Population mean:&quot;, np.mean(population))<br>print(&quot;Population standard deviation:&quot;, np.std(population))</pre><pre>Population mean: 0.9959701590561849<br>Population standard deviation: 0.9929690473143962</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*DEV9QpViyJpLZ_a4T7PEZA.png" /></figure><pre>def get_sample_means(n, repetitions=10000):<br>    sample_means = []<br><br>    for _ in range(repetitions):<br>        sample = np.random.choice(population, size=n)<br>        sample_mean = np.mean(sample)<br>        sample_means.append(sample_mean)<br><br>    return np.array(sample_means)<br><br>n = 5<br><br>sample = np.random.choice(population, size=5)<br>sample_mean = np.mean(sample)<br>means_5 = get_sample_means(5)<br><br>plt.figure(figsize=(8, 5))<br><br>plt.hist(means_5, bins=50, density=True)<br><br>plt.xlabel(&quot;Sample Mean&quot;)<br>plt.ylabel(&quot;Density&quot;)<br>plt.title(&quot;Sampling Distribution of the Mean (n = 5)&quot;)<br><br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*mcB5VAqqcxu8TQdNi0XDqw.png" /></figure><pre>means_30 = get_sample_means(30)<br><br>plt.figure(figsize=(8, 5))<br><br>plt.hist(means_30, bins=50, density=True)<br><br>plt.xlabel(&quot;Sample Mean&quot;)<br>plt.ylabel(&quot;Density&quot;)<br>plt.title(&quot;Sampling Distribution of the Mean (n = 30)&quot;)<br><br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*F5fFLv9QQ3G1gdAKtCA3wg.png" /></figure><pre>means_100 = get_sample_means(100)<br><br>plt.figure(figsize=(8, 5))<br><br>plt.hist(means_100, bins=50, density=True)<br><br>plt.xlabel(&quot;Sample Mean&quot;)<br>plt.ylabel(&quot;Density&quot;)<br>plt.title(&quot;Sampling Distribution of the Mean (n = 100)&quot;)<br><br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*FyQTRFliJJBa7mrZ7aZdTQ.png" /></figure><p>We saw, right? On increasing the value of n we are approaching the <strong>Normal Distribution</strong>.</p><p>Let’s compare them together:</p><pre>plt.figure(figsize=(10, 6))<br><br>plt.hist(means_5, bins=50, density=True, alpha=0.5, label=&quot;n = 5&quot;)<br>plt.hist(means_30, bins=50, density=True, alpha=0.5, label=&quot;n = 30&quot;)<br>plt.hist(means_100, bins=50, density=True, alpha=0.5, label=&quot;n = 100&quot;)<br><br>plt.xlabel(&quot;Sample Mean&quot;)<br>plt.ylabel(&quot;Density&quot;)<br>plt.title(&quot;Effect of Sample Size on the Sampling Distribution&quot;)<br><br>plt.legend()<br><br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*90nEZMUXP3QaA-qR3TmAfg.png" /></figure><p>Aren’t we clear now? We did an experiment and it really got validated by the <strong>CLT</strong>.</p><p>But wait, why do we even need this? Why are we focusing so much on the <strong>Normal Distribution</strong> and why not some other?</p><p>As we discussed earlier too, we generally do not have population data, so we deal with sample data and try to know things about the population data. But how much can we rely on our sample results? The sampling distribution helps answer that. <strong>CLT</strong> tells us how (X̄) behaves. We know its <em>mean</em> and <em>variance</em>, and it is <em>approximately normally distributed</em>. That is extremely useful because the normal distribution is mathematically well understood.</p><p>We already know, right? The 68–95–99.7 rule.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Rgg0_22qiqShzEcJFTjlgw.png" /></figure><p>With the help of normal distribution, known mean and variance we can build a 95% confidence interval:</p><p>X̄ ± 1.96(SE)</p><p>and in the same way, results could be drawn for 68% and 99.7% confidence intervals (using 1 and 3 standard errors respectively).</p><p>Also, this is very useful in <strong>Hypothesis Testing</strong> and <strong>A/B Testing</strong>. Do not worry, we will learn about these in my future blogs. Till then <em>HAPPY LEARNING</em>.</p><h3>Resources</h3><ul><li><a href="https://github.com/MansiBramta/Sampling_Distribution_And_Central_Limit_Theorem"><strong>GitHub Repository</strong></a></li><li><a href="https://www.kaggle.com/code/mansibramta/sampling-distribution-the-central-limit-theorem"><strong>Kaggle Notebook</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=668a53b3b548" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Continuous Probability Distributions: From Curves to Probability]]></title>
            <link>https://medium.com/@mansibramta12/continuous-probability-distributions-from-curves-to-probability-020ca3d8901e?source=rss-4e5a6b578be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/020ca3d8901e</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <dc:creator><![CDATA[Mansi Bramta]]></dc:creator>
            <pubDate>Sat, 26 Sep 2026 17:08:56 GMT</pubDate>
            <atom:updated>2026-09-26T17:08:56.942Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZDwlcEE7vRBJ-dSiFlqh2A.png" /></figure><h4>Understanding Uniform, Normal, Exponential, Gamma, and Beta distributions through intuition, mathematics, and real-world examples</h4><p>In my previous blog “Bernoulli Asked “Success or Failure.” Poisson Asked “How Many?” I already discussed <em>Discrete Probability Distributions</em>.</p><p>I took a deep dive into the 6 most important <em>distributions</em> in it. Moving a step ahead, now it is turn of <strong>Continuous Probability Distributions</strong>. Similarly as I dissected my last blog word by word, in the same fashion I’m going to open layers of this blog.</p><p>Now I think we are very much clear about the topics like <em>Random Variable</em> and <em>Probability Distributions</em>. So as the name suggests, “Continuous Probability Distributions” are used when the random variable can take values from a continuous range, such as X ∈ [0,1].</p><p>As discussed earlier, to understand the structure of the data and get proper knowledge of what we are working with we should know about the <em>Probability Distributions</em>.</p><p>The function for <strong>Continuous Probability Distributions</strong> is called <strong>“Probability Density Function (PDF)”</strong>. I would like to mention here again that, the function here is called so because unlike “Discrete Probability Distributions”, here we deal with area under the graph over an interval. The probability at any exact point is 0, so we work with intervals instead. Working with an interval makes it more feasible and interpretable. Hence the name <strong>Density</strong> came into picture. This was just a brief discussion, if you want to learn about it more please go check out my blog <strong>“PMF, PDF &amp; CDF: Three Ways Probability Helps Us Understand Data”</strong> on Medium.</p><p>Two most important things to keep in mind about <em>PDF</em>:</p><ol><li>f(x) ≥ 0</li><li>∫ f(x) dx = 1, over (−∞, ∞)</li></ol><p>Just to be sure from my side that no confusion is left between <em>PMF</em> and <em>PDF</em> I am providing you with the summary table below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*M-6LFm0duaO4C9fT7SfRiA.png" /></figure><p>Also I hope we are well familiar here with <strong>Cumulative Distribution Function</strong>. Just a brief intro:</p><p>F(x) = P(X ≤ x)</p><p>and it is the area under the PDF from (−∞) to (x).</p><p><em>Differentiating the </em><strong><em>CDF</em></strong><em> gives the </em><strong><em>PDF</em></strong><em> where the derivative exists.</em></p><h3>Expected Value and Variance for Continuous Variables</h3><p>Mean:</p><p>E[X] = ∫ x·f(x) dx, over (−∞, ∞)</p><p>Instead of multiplying each possible value by its probability, we now weight every possible value by its density and integrate.</p><p>Variance:</p><p>Var(X) = E[(X − μ)²]</p><p>and</p><p>Var(X) = E[X²] − μ²</p><p>where</p><p>E[X²] = ∫ x²·f(x) dx, over (−∞, ∞)</p><p>There are many Continuous Distributions but here is my blog we will be discussing main 5 of them:</p><ul><li>Uniform Distribution</li><li>Normal Distribution</li><li>Exponential Distribution</li><li>Gamma Distribution</li><li>Beta Distribution</li></ul><p>Let’s begin with our first one,</p><p><strong>1. Uniform Distribution</strong></p><p>What if we choose an interval and the density is the same throughout that interval, it is called <em>“Uniform”</em> right and hence we are dealing with probability we will get a <em>distribution</em>, making the name suitable as <strong>Uniform Distribution</strong>.</p><p>We denote it as</p><h3><strong><em>X ~ U(a,b)</em></strong></h3><p>and (a,b) represents a ≤ X ≤ b. The distinction at the endpoints doesn’t affect the probability because individual points have probability zero, but your PDF later uses a ≤ x ≤ b, so make the notation consistent.</p><p>The thing to note here is, for a <strong>continuous random variable</strong>, the probability at any exact point is zero.</p><p>So, as talked above the distribution is uniform hence it should look something like rectangle. Hence the <strong>PDF</strong> is 1/(b−a) where, a ≤ x ≤ b.</p><p>Let us unfold the PDF, <em>The total area under a PDF must equal 1</em> and we already know it distribution looks like rectangle so,</p><p>Area = width × height</p><p>(b − a) × f(x) = 1</p><p>Therefore,</p><p>f(x) = 1/(b − a)</p><p>Outside the interval the density remains 0.</p><p>A discussion about distributions is incomplete till we talk about its <em>mean</em> and <em>variance</em>.</p><p>So <strong>Mean</strong> as mentioned above looks something like, E[X] = ∫ x·f(x) dx, over (−∞, ∞), here by substituting the value of <em>f(x)</em> from above we will get</p><p>E[X] = ∫ₐᵇ x·(1/(b−a)) dx</p><p>after integration we are left with result,</p><p>E[X] = (1/(b−a))·[x²/2] from a to b</p><p>E[X] = (1/(b−a))·(b²/2 − a²/2) = (b² − a²)/(2(b−a))</p><p>Factor the numerator using the difference of squares:</p><p>b² − a² = (b−a)(b+a)</p><p>So:</p><p>E[X] = (b−a)(b+a)/(2(b−a))</p><p>Cancel (b−a):</p><p>E[X] = (a+b)/2</p><p>This result makes sense.</p><p>If every point between a and b is equally represented, the average lies exactly in the middle.</p><p>Variance on the other hand is,</p><p>E[X²] = ∫ x²·f(x) dx, over (−∞, ∞)</p><p>again substituting the value of <em>f(x)</em>,</p><p>E[X²] = ∫ₐᵇ x²·(1/(b−a)) dx</p><p>E[X²] = (1/(b−a))·[x³/3] from a to b = (b³ − a³)/(3(b−a))</p><p>Using the difference of cubes:</p><p>b³ − a³ = (b−a)(b² + ab + a²)</p><p>we get:</p><p>E[X²] = (a² + ab + b²)/3</p><p>We already know:</p><p>E[X] = (a+b)/2</p><p>Therefore,</p><p>Var(X) = (a² + ab + b²)/3 − ((a+b)/2)²</p><p>After simplifying:</p><p>Var(X) = (b−a)²/12</p><p>Now let us see it through an example,</p><p><strong>Question:</strong></p><p>Imagine you are listening to a playlist on shuffle. Your favourite song is somewhere in a 30-minute podcast, and you have no information suggesting that it is more likely to occur at one particular time than another.</p><p>Let X be the time, in minutes, at which the song starts.</p><p>We assume:</p><p>X ~ U(0,30)</p><p>So the song could start anywhere between 0 and 30 minutes, with equal probability density.</p><ol><li>What is the probability that the song starts between 10 and 18 minutes?</li></ol><p>The total interval is:</p><p>30 − 0 = 30</p><p>The interval we’re interested in is:</p><p>18 − 10 = 8</p><p>Therefore:</p><p>P(10 &lt; X &lt; 18) = (18−10)/(30−0) = 8/30 = 4/15 ≈ 0.2667</p><p>So:</p><p>P(10 &lt; X &lt; 18) ≈ 26.67%</p><ol><li>What is the expected time?</li></ol><p>For a Uniform Distribution:</p><p>E[X] = (a+b)/2</p><p>Therefore:</p><p>E[X] = (0+30)/2 = 15</p><p>So the expected time is 15 minutes.</p><p>This doesn’t mean the song will actually start at exactly 15 minutes. It means that if we repeated this situation many times, the average starting time would approach 15 minutes.</p><ol><li>What is the variance?</li></ol><p>The variance is:</p><p>Var(X) = (b−a)²/12</p><p>Therefore:</p><p>Var(X) = (30−0)²/12 = 900/12 = 75</p><p>And the standard deviation is:</p><p>σ = √75 ≈ 8.66</p><p>So:</p><p>σ ≈ 8.66</p><p>8.66 minutes</p><pre><em>This is a modeling assumption. In a real playlist, song positions aren&#39;t necessarily uniformly distributed.</em></pre><pre>import numpy as np<br>from scipy.stats import uniform<br>import matplotlib.pyplot as plt</pre><pre># Parameters<br>a = 0<br>b = 30</pre><pre># Create Uniform Distribution<br>X = uniform(loc= a,scale= b-a)</pre><pre># Create x values<br>x = np.linspace(a,b,1000)</pre><pre># Calculate PDF<br>pdf = X.pdf(x)</pre><pre># Mean and standard deviation<br>mean = X.mean()<br>std = X.std()</pre><pre>print(&quot;Mean:&quot;, mean)<br>print(&quot;Variance:&quot;, X.var())<br>print(&quot;Standard Deviation:&quot;, std)</pre><pre># Plot<br>plt.figure(figsize=(10, 5))</pre><pre>plt.plot(x, pdf, linewidth=2)</pre><pre># Mean<br>plt.axvline(mean, linestyle=&quot;--&quot;, linewidth=2,<br>            label=f&quot;Mean = {mean:.0f} minutes&quot;)</pre><pre># One standard deviation on each side<br>plt.axvline(mean - std, linestyle=&quot;:&quot;, linewidth=2,<br>            label=f&quot;Mean - SD = {mean-std:.2f}&quot;)</pre><pre>plt.axvline(mean + std, linestyle=&quot;:&quot;, linewidth=2,<br>            label=f&quot;Mean + SD = {mean+std:.2f}&quot;)</pre><pre>plt.xlabel(&quot;Time after the start of the podcast (minutes)&quot;)<br>plt.ylabel(&quot;Probability Density&quot;)<br>plt.title(&quot;Uniform Distribution: Song Start Time&quot;)<br>plt.legend()<br>plt.grid(alpha=0.3)</pre><pre>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*NjoCypO0BQanUCkRsfI1DQ.png" /></figure><p><strong>2. Normal Distribution</strong></p><p>Before understanding this, I want you to appreciate the fact that this is the most widely used distribution. One must have good understanding of <em>Normal Distribution</em> to understand many algorithms used in machine learning.</p><p>To understand this, we should first discuss <strong>z-score</strong>, it is:</p><pre>How far is a value x from the mean, measured in standard deviations?How far is a value x from the mean, measured in standard deviations?</pre><p><em>“measured in standard deviations”</em> can sound confusing so in simpler way we can understand it as:</p><p><em>“Instead of measuring distance in the original units, we measure how many standard deviations away from the mean the value is.”</em></p><p>i.e if σ = 10 units then 1 standard deviation = 10 units.</p><p><em>Positive z-score</em> z &gt; 0</p><p>means the value is above the mean.</p><p><em>Negative z-score</em> z &lt; 0</p><p>means the value is below the mean.</p><p><em>Zero z-score</em> z = 0</p><p>means:</p><p>x = μ</p><p>The value is exactly at the mean.</p><p>But isn’t it a valid thing to ask, why do we need to divide it by standard deviation?</p><p>We must clear this with an example:</p><p>Test 1:</p><p>Mean = 70</p><p>SD = 10</p><p>Score = 80</p><p>z = (80−70)/10 = 1</p><p>Test 2</p><p>Mean = 50</p><p>SD = 5</p><p>Score = 55</p><p>The raw scores are completely different:</p><p>80 ≠ 55</p><p>But:</p><p>z = (55−50)/5 = 1</p><p>Both students are:</p><p>1 SD above their respective means</p><p>So their relative positions within their distributions are the same.</p><p>That’s the power of the standardization. Therefore we say <strong>Z-score is a standardized score.</strong></p><p>One must not confuse <em>z-score</em> with <em>probability.</em></p><p><em>z = 1</em> and <em>P(X = 1) = 1</em> are not the same thing. To get probability, we need to use the <strong>Normal Distribution/CDF</strong>.</p><pre>&quot;A z-score doesn&#39;t tell us how large a value is, it tells us where that value stands relative to the mean, measured in standard deviations.&quot;</pre><p>The mathematical notation is:</p><h3><strong>X ~ N(μ, σ²)</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*1-qyBjb5YU7cTp5VI17Hjw.png" /></figure><p>Usually:</p><ol><li>Most observations are somewhere around the average.</li><li>Fewer observations are far away from the average.</li><li>Very extreme values are rare.</li></ol><p><strong>That gives us the familiar bell-shaped curve.</strong></p><p>A normal distribution has three important characteristics:</p><ol><li>It is symmetric</li><li>Mean = Median = Mode = μ</li><li>The tails get closer and closer to zero</li></ol><p>The <strong>PDF</strong> here is:</p><p>f(x) = (1/(σ√(2π))) · e^(−(1/2)·((x−μ)/σ)²)</p><p>Isn’t it scary at first glance? But let us break through it.</p><p>The part inside the exponent, i.e. (x−μ)/σ, is the z-score, now we are clear with it I hope.</p><p>We are squaring the z-score to get the symmetric values, if we don’t square, it will give different values for positive and negative exponential, which won’t make it symmetrical. Hence squaring solves our problem.</p><p>The farther x moves from μ, the larger z² becomes, so the density becomes smaller.</p><p>That’s why we get a bell shape.</p><p>But what is the need? We had above <em>Uniform Distributions’s PDF</em>, that was so simple why couldn’t we use it as it is?</p><p>In case of <em>Uniform Distribution PDF</em> we were dealing with uniform density, so the graph was rectangular but here as far as a point moves from its mean the density decreases or the density changes depending on how far we are from the mean.</p><p>At the center:</p><p>x = μ</p><p>so:</p><p>f(μ) = 1/(σ√(2π))</p><p>This is the highest point of the curve.</p><p>As x moves away from μ, the density decreases.</p><p>The normal density is defined so that</p><p>∫ e^(−z²/2) dz = √(2π), over (−∞, ∞)</p><p>Therefore, to make the total area equal to 1, we divide by √(2π)</p><p>That’s where we get:</p><p>(1/√(2π)) · e^(−z²/2)</p><p>This is called the <strong>standard normal distribution.</strong></p><p>So:</p><p>1/√(2π)</p><p>normalizes the total area to 1.</p><p>And lastly dividing by σ adjusts the height when the curve is stretched/compressed.</p><p>The <strong>Mean</strong> here is:</p><p>E[X] = μ</p><p><em>(Where is the bell curve located?)</em></p><p>and the <strong>Variance</strong> is:</p><p>Var(X) = σ²</p><p><em>(How wide or narrow is the bell curve?)</em></p><p>Do you remember at the very beginning I told you this is the most widely used distribution, in the further section you will realise the same.</p><p><strong>The famous 68–95–99.7 rule</strong></p><p>Within 1 standard deviation μ − σ &lt; X &lt; μ + σ</p><p>contains about:</p><p>68% of the observations.</p><p>Within 2 standard deviations μ − 2σ &lt; X &lt; μ + 2σ</p><p>contains approximately:</p><p>95%</p><p>Within 3 standard deviations μ − 3σ &lt; X &lt; μ + 3σ</p><p>contains approximately:</p><p>99.7%</p><p>So visually:</p><p>68% — 95% — 99.7%</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Rgg0_22qiqShzEcJFTjlgw.png" /></figure><p>About 68% of observations lie within 1 standard deviation of the mean.</p><p>It’s the area under the curve between -1 and +1.</p><p>So:</p><p>P(−1 ≤ Z ≤ 1) = 0.682</p><p>The normal distribution is symmetric. Therefore splitting 68.2 into half gives us 34.1%.</p><p>About 95.4% of observations are within 2 standard deviations of the mean.</p><p>Then between 2σ and 3σ:</p><p>2.1%</p><p>on each side.</p><p><strong>Question</strong></p><p>Imagine 1000 students</p><p>Suppose their exam scores follow a normal distribution.</p><p>Say:</p><p>μ = 70, σ = 10</p><p>So:</p><p>Mean = 70</p><p>1 SD = 10</p><p>That means:</p><p>μ − 1σ = 60 μ + 1σ = 80</p><p>Now look at the green region:</p><p>60 ≤ X ≤ 80</p><p>The graph says 68.2%.</p><p>What does 68.2% actually mean?</p><p>It means:</p><p>Out of 100 students, approximately 68 students would have scores between 60 and 80.</p><p>Or out of 1000:</p><p>1000 × 0.682 = 682</p><p>So approximately 682 students would fall between 60 and 80.</p><p>That’s what the percentage represents.</p><p>Now we make the interval wider.</p><p>Instead of going only 1 SD from the mean, go 2 SD:</p><p>μ − 2σ to μ + 2σ</p><p>For our example:</p><p>70 − 20 = 50</p><p>to</p><p>70 + 20 = 90</p><p>The graph says:</p><p>95.4%</p><p>So approximately 95.4% of all students would have scores between 50 and 90.</p><p>Notice what’s happening:</p><p>Within 1 SD 60 → 80</p><p>contains:</p><p>68.2%</p><p>Within 2 SD 50 → 90</p><p>contains:</p><p>95.4%</p><p>Within 3 SD 40 → 100</p><p>contains:</p><p>99.7%</p><p>We’re simply capturing more and more of the total area under the curve.</p><p>Look at the tiny red region.</p><p>The graph says:</p><p>0.1%</p><p>That means only about 0.1% of observations are beyond 3 SD on that particular side.</p><p>For 1000 students:</p><p>1000 × 0.001 = 1</p><p>So roughly 1 student might be beyond 3σ on one side.</p><p>This is why extreme observations are rare in a normal distribution.</p><p>So remember:</p><pre>Height of curve = density <br>Area under a region = probability/percentage of observations</pre><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from scipy.stats import norm</pre><pre># Parameters<br>mu = 70<br>sigma = 10</pre><pre># x values<br>x = np.linspace(30, 110, 1000)</pre><pre># Normal distribution<br>y = norm.pdf(x, mu, sigma)</pre><pre># Create figure<br>plt.figure(figsize=(12, 6))</pre><pre># Plot normal curve<br>plt.plot(x, y, color=&quot;black&quot;, linewidth=2)</pre><pre># Shade within 1 standard deviation<br>x1 = np.linspace(mu - sigma, mu + sigma, 500)<br>y1 = norm.pdf(x1, mu, sigma)</pre><pre>plt.fill_between(<br>    x1, y1,<br>    alpha=0.5,<br>    label=&quot;Within 1 SD = 68.2%&quot;<br>)</pre><pre># Shade between 1 and 2 standard deviations<br>x2_left = np.linspace(mu - 2*sigma, mu - sigma, 300)<br>x2_right = np.linspace(mu + sigma, mu + 2*sigma, 300)</pre><pre>plt.fill_between(<br>    x2_left,<br>    norm.pdf(x2_left, mu, sigma),<br>    alpha=0.35,<br>    label=&quot;Between 1 and 2 SD = 27.2%&quot;<br>)</pre><pre>plt.fill_between(<br>    x2_right,<br>    norm.pdf(x2_right, mu, sigma),<br>    alpha=0.35<br>)</pre><pre># Shade between 2 and 3 standard deviations<br>x3_left = np.linspace(mu - 3*sigma, mu - 2*sigma, 200)<br>x3_right = np.linspace(mu + 2*sigma, mu + 3*sigma, 200)</pre><pre>plt.fill_between(<br>    x3_left,<br>    norm.pdf(x3_left, mu, sigma),<br>    alpha=0.2,<br>    label=&quot;Between 2 and 3 SD = 4.2%&quot;<br>)</pre><pre>plt.fill_between(<br>    x3_right,<br>    norm.pdf(x3_right, mu, sigma),<br>    alpha=0.2<br>)</pre><pre># Mark mean and standard deviations<br>values = [<br>    mu - 3*sigma,<br>    mu - 2*sigma,<br>    mu - sigma,<br>    mu,<br>    mu + sigma,<br>    mu + 2*sigma,<br>    mu + 3*sigma<br>]</pre><pre>labels = [<br>    &quot;-3σ\n40&quot;,<br>    &quot;-2σ\n50&quot;,<br>    &quot;-1σ\n60&quot;,<br>    &quot;μ\n70&quot;,<br>    &quot;+1σ\n80&quot;,<br>    &quot;+2σ\n90&quot;,<br>    &quot;+3σ\n100&quot;<br>]</pre><pre>for value, label in zip(values, labels):<br>    plt.axvline(value, color=&quot;black&quot;, linewidth=1)<br>    plt.text(<br>        value,<br>        -0.002,<br>        label,<br>        ha=&quot;center&quot;,<br>        va=&quot;top&quot;,<br>        fontsize=11<br>    )</pre><pre># Percentage labels<br>plt.text(70, 0.025, &quot;68.2%&quot;, ha=&quot;center&quot;, fontsize=14)<br>plt.text(55, 0.012, &quot;13.6%&quot;, ha=&quot;center&quot;, fontsize=12)<br>plt.text(85, 0.012, &quot;13.6%&quot;, ha=&quot;center&quot;, fontsize=12)<br>plt.text(45, 0.004, &quot;2.1%&quot;, ha=&quot;center&quot;, fontsize=11)<br>plt.text(95, 0.004, &quot;2.1%&quot;, ha=&quot;center&quot;, fontsize=11)</pre><pre># Titles and labels<br>plt.title(<br>    &quot;Normal Distribution of Exam Scores&quot;,<br>    fontsize=16<br>)</pre><pre>plt.xlabel(&quot;Exam Score&quot;)<br>plt.ylabel(&quot;Probability Density&quot;)</pre><pre>plt.xlim(30, 110)<br>plt.ylim(-0.01, 0.045)</pre><pre>plt.grid(alpha=0.2)</pre><pre>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wSqzHJ8DZxurRpgy4xYMaQ.png" /></figure><p><strong>3. Exponential Distribution</strong></p><p>In my last blog I talked about <strong>Poisson Distribution</strong>, which was answering <em>“how many events are happening in a fixed time interval.”</em> On the same idea, <strong>Exponential Distribution</strong> is answering <em>“how much time till the next event”</em>. Generally represented as:</p><h3><strong>X ~ Exponential(λ)</strong></h3><p>The <strong>PDF</strong> is:</p><p>f(x) = λ·e^(−λx), x ≥ 0</p><p>where:</p><p>X = waiting time</p><p>λ = rate at which events occur</p><p>e = Euler’s number, approximately 2.718</p><p>Now let us discuss how we ended up with this, Let’s suppose events happen randomly at a constant rate λ, following a Poisson process.</p><p>X = waiting time until the next customer</p><p>We want to find the distribution of X.</p><p>First find P(X&gt;x): <em>(What is the probability that I have to wait MORE than x units of time? which means: No event occurred during the first x units of time.)</em></p><p>If events occur at rate λ, then the number of events in time x follows:</p><p>N(x) ~ Poisson(λx)</p><p>which means events per unit time × unit of time = events expected in x times.</p><p>Therefore:</p><p>P(X &gt; x) = P(N(x) = 0)</p><p>Now use the Poisson PMF:</p><p>P(N=k) = (e^(−λx)·(λx)^k) / k!</p><p>Since we want k=0:</p><p>P(N(x)=0) = (e^(−λx)·(λx)⁰) / 0!</p><p>Now:</p><p>(λx)⁰ = 1</p><p>and</p><p>0! = 1</p><p>so we’re left with:</p><p>P(X &gt; x) = e^(−λx)</p><p>This is where the negative exponential comes from.</p><p>It isn’t randomly chosen.</p><p>It comes directly from the Poisson probability of getting zero events.</p><p>The CDF asks:</p><p>P(X ≤ x)</p><p>Since either X ≤ x or X &gt; x:</p><p>P(X ≤ x) + P(X &gt; x) = 1</p><p>Therefore:</p><p>F(x) = 1 − e^(−λx)</p><p>This is the CDF of the Exponential Distribution.</p><p>For a continuous distribution:</p><p>f(x) = F′(x)</p><p>So differentiate:</p><p>F(x) = 1 − e^(−λx)</p><p>with respect to x.</p><p>so:</p><p>f(x) = −(−λ·e^(−λx))</p><p>and therefore:</p><p>f(x) = λ·e^(−λx)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*80xZKaX7HEOG2yKwszwKZA.png" /></figure><p>This is how the exponential distribution looks like. The curve starts high and decreases. The important thing is that the curve never actually reaches zero.</p><p>It gets closer and closer to zero because very long waiting times are possible, but increasingly unlikely.</p><p>The <strong>Mean</strong> is:</p><p>E[X] = 1/λ</p><p>and the <strong>Variance</strong> is:</p><p>Var(X) = 1/λ²</p><p>Now let us see it through an example,</p><p><strong>Question:</strong></p><p>Suppose customers arrive at a café at an average rate of:</p><p>λ = 2 customers per hour</p><p>Let X be the waiting time in hours until the next customer arrives.</p><p>Therefore,</p><p>X ~ Exponential(λ=2)</p><p>Its PDF is:</p><p>f(x) = 2·e^(−2x), x ≥ 0</p><ol><li>What is the probability that we wait more than 1 hour?</li></ol><p>Using:</p><p>P(X &gt; x) = e^(−λx)</p><p>we get:</p><p>P(X &gt; 1) = e^(−2(1)) P(X &gt; 1) ≈ 0.1353</p><p>So there is about a 13.53% probability of waiting more than one hour.</p><p>Here,</p><p>Mean = 1/λ = 1/2 = 0.5 hour</p><p>So the average waiting time is 30 minutes.</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from scipy.stats import expon</pre><pre># Rate<br>lambda_ = 2</pre><pre># Mean waiting time<br>mean = 1 / lambda_</pre><pre># Create x values<br>x = np.linspace(0, 3, 500)</pre><pre># Exponential PDF<br>pdf = expon.pdf(x, scale=1/lambda_)</pre><pre># Plot<br>plt.figure(figsize=(9, 5))</pre><pre>plt.plot(x, pdf, label=&quot;Exponential PDF&quot;)</pre><pre># Mark the mean<br>plt.axvline(<br>    mean,<br>    linestyle=&quot;--&quot;,<br>    label=f&quot;Mean = {mean:.2f} hour&quot;<br>)</pre><pre>plt.xlabel(&quot;Waiting time (hours)&quot;)<br>plt.ylabel(&quot;Probability density&quot;)<br>plt.title(&quot;Exponential Distribution: Waiting Time for Next Customer&quot;)<br>plt.legend()<br>plt.grid(alpha=0.3)</pre><pre>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*WDVeViCLzjm_2V1WjvANTw.png" /></figure><p><strong>4. Gamma Distribution</strong></p><p>The Gamma distribution is a distribution used to model waiting time until multiple events occur. It is denoted as:</p><h3>X∼Gamma(k,λ)</h3><p>The <strong>PDF</strong> is:</p><p>f(x) = (λᵏ / Γ(k)) · x^(k−1) · e^(−λx), x ≥ 0</p><p>where:</p><p>k = shape parameter</p><p>λ = rate parameter</p><p>x = waiting time</p><p>Γ(k) = Gamma function</p><p>The important part is:</p><p>x^(k−1)·e^(−λx)</p><p>You can see the connection with the Exponential distribution:</p><p>f(x) = λ·e^(−λx)</p><p>If k=1, Gamma becomes Exponential:</p><p>(λ¹/Γ(1))·x⁰·e^(−λx) = λ·e^(−λx)</p><p>because</p><p>Γ(1) = 1</p><p>So exponential distribution is actually a special case of the Gamma distribution.</p><p>For the k-th event to happen around x, we need k−1 events to have happened before x.</p><p>The probability of getting k−1 events in time x contains a term proportional to</p><p>(λx)^(k−1)</p><p>So we get:</p><p>(λx)^(k−1)·e^(−λx)</p><p>Now expand the first part:</p><p>(λx)^(k−1) = λ^(k−1)·x^(k−1)</p><p>Therefore,</p><p>λ^(k−1)·x^(k−1)·e^(−λx)</p><p>This gives us the basic shape of the Gamma density. The remaining constants are needed to normalize the function so that the total area is 1.</p><p>The Gamma function is defined as</p><p>Γ(k) = ∫₀^∞ t^(k−1)·e^(−t) dt</p><p>And for positive integers:</p><p>Γ(k) = (k−1)!</p><p>So:</p><p>Γ(1) = 0! = 1</p><p>Γ(2) = 1! = 1</p><p>Put k=1 into Gamma:</p><p>f(x) = (λ¹/Γ(1))·x^(1−1)·e^(−λx)</p><p>Since</p><p>Γ(1) = 1</p><p>and</p><p>x⁰ = 1</p><p>we get:</p><p>f(x) = λ·e^(−λx)</p><p>which is exactly the Exponential distribution.</p><p>So:</p><p>Gamma with k=1 = Exponential</p><p>That’s not a coincidence.</p><p>It makes sense because:</p><p>Gamma asks: “How long until the k-th event?”</p><p>When k=1, that’s simply “How long until the first event?”</p><p>For the rate parameterization:</p><p>X ~ Gamma(k, λ)</p><p>the <strong>Mean</strong> is</p><p>E[X] = k/λ</p><p>and <strong>Variance</strong> is</p><p>Var(X) = k/λ²</p><p><strong>Question</strong></p><p>Customers arrive at a coffee shop at an average rate of 4 customers per hour. What is the probability density of the waiting time until the 5th customer arrives? Also, what is the expected waiting time?</p><p>Here:</p><p>λ = 4 customers/hour</p><p>and</p><p>k = 5</p><p>So,</p><p>X ~ Gamma(5, 4)</p><p>The PDF is</p><p>f(x) = (⁴⁵/Γ(5))·x^(5−1)·e^(−4x)</p><p>Since</p><p>Γ(5) = 4! = 24</p><p>we get</p><p>f(x) = (1024/24)·x⁴·e^(−4x)</p><p>Expected waiting time</p><p>E[X] = k/λ</p><p>Therefore,</p><p>E[X] = 5/4 = 1.25 hours</p><p>So we expect to wait 1.25 hours (75 minutes) for the 5th customer.</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from scipy.stats import gamma</pre><pre># Parameters<br>k = 5<br>lam = 4</pre><pre># x = waiting time in hours<br>x = np.linspace(0, 3, 500)</pre><pre># Gamma PDF<br>pdf = gamma.pdf(x, a=k, scale=1/lam)</pre><pre># Mean<br>mean = k / lam</pre><pre># Plot<br>plt.figure(figsize=(8, 5))</pre><pre>plt.plot(x, pdf, label=&quot;Gamma PDF&quot;)<br>plt.axvline(mean, linestyle=&quot;--&quot;, label=f&quot;Mean = {mean:.2f} hours&quot;)</pre><pre>plt.xlabel(&quot;Waiting Time (hours)&quot;)<br>plt.ylabel(&quot;Probability Density&quot;)<br>plt.title(&quot;Waiting Time Until the 5th Customer Arrives&quot;)<br>plt.legend()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*pLd3H-cx-f_0K2BVWNaLXw.png" /></figure><p><strong>5. Beta Distribution</strong></p><p>It is used when the variable we’re studying is restricted to a fixed interval between 0 and 1. The notation is:</p><h3><strong>X∼Beta(α,β)</strong></h3><p>The <strong>PDF</strong> is:</p><p>f(x) = (1/B(α,β))·x^(α−1)·(1−x)^(β−1)</p><p>where</p><p>0 ≤ x ≤ 1</p><p>and:</p><p>α = first shape parameter</p><p>β = second shape parameter</p><p>The first thing to notice is:</p><p>x^(α−1)</p><p>and</p><p>(1−x)^(β−1)</p><p>These two terms control the shape of the distribution.</p><p>Since we often use the Beta distribution to model proportions or probabilities, it is defined on 0 ≤ x ≤ 1.</p><p>We want a function that can take different shapes depending on what we believe about that proportion.</p><p>Consider:</p><p>x^(α−1)</p><p>This controls what happens as x approaches 0.</p><p>And:</p><p>(1−x)^(β−1)</p><p>controls what happens as x approaches 1.</p><p>So we combine them:</p><p>x^(α−1)·(1−x)^(β−1)</p><p>This gives us the basic shape.</p><p>But just like with Gamma, this isn’t automatically a valid PDF.</p><p>We need its total area to equal 1:</p><p>∫₀¹ f(x) dx = 1</p><p>So we divide by the appropriate normalization constant:</p><p>B(α,β)</p><p>giving:</p><p>f(x) = (x^(α−1)·(1−x)^(β−1)) / B(α,β)</p><p>The Beta function is</p><p>B(α,β) = ∫₀¹ x^(α−1)·(1−x)^(β−1) dx</p><p>It basically calculates the area under the unnormalized curve.</p><p>Case 1: α=1, β=1</p><p>f(x) = 1</p><p>This gives a uniform distribution between 0 and 1.</p><p>Every value has the same density.</p><p>Case 2: α &gt; β</p><p>For example:</p><p>α=5, β=2</p><p>The distribution tends to concentrate toward 1.</p><p>Case 3: α &lt; β</p><p>For example:</p><p>α=2, β=5</p><p>The distribution tends to concentrate toward 0.</p><p>Case 4: α = β &gt; 1</p><p>For example:</p><p>α=5, β=5</p><p>The distribution becomes symmetric around 0.5.</p><p>The <strong>Mean</strong> is:</p><p>E[X] = ∫₀¹ x·(1/B(α,β))·x^(α−1)·(1−x)^(β−1) dx</p><p>Take the constant outside:</p><p>E[X] = (1/B(α,β))·∫₀¹ x^α·(1−x)^(β−1) dx</p><p>Now notice something important.</p><p>The Beta function is:</p><p>B(a,b) = ∫₀¹ x^(a−1)·(1−x)^(b−1) dx</p><p>Our integral is:</p><p>∫₀¹ x^α·(1−x)^(β−1) dx</p><p>We can rewrite</p><p>x^α = x^((α+1)−1)</p><p>Therefore:</p><p>∫₀¹ x^α·(1−x)^(β−1) dx = B(α+1, β)</p><p>So:</p><p>E[X] = B(α+1,β) / B(α,β)</p><p>Now we use the Gamma-function relationship:</p><p>B(α,β) = (Γ(α)·Γ(β)) / Γ(α+β)</p><p>Therefore,</p><p>B(α+1,β)/B(α,β) = [Γ(α+1)·Γ(β)/Γ(α+β+1)] / [Γ(α)·Γ(β)/Γ(α+β)]</p><p>Now cancel the common terms:</p><p>= (Γ(α+1)/Γ(α)) · (Γ(α+β)/Γ(α+β+1))</p><p>And remember:</p><p>Γ(α+1) = α·Γ(α)</p><p>and</p><p>Γ(α+β+1) = (α+β)·Γ(α+β)</p><p>Therefore the <strong>Mean</strong> is:</p><p>E[X] = α/(α+β)</p><p>and the <strong>Variance</strong> goes like:</p><p>Var(X) = E[X²] − [E[X]]²</p><p>We already know:</p><p>E[X] = α/(α+β)</p><p>So now we need:</p><p>E[X²] = ∫₀¹ x²·f(x) dx</p><p>Substitute the PDF:</p><p>E[X²] = (1/B(α,β))·∫₀¹ x²·x^(α−1)·(1−x)^(β−1) dx</p><p>Combine the powers:</p><p>x²·x^(α−1) = x^(α+1)</p><p>Therefore:</p><p>E[X²] = (1/B(α,β))·∫₀¹ x^(α+1)·(1−x)^(β−1) dx</p><p>Again recognize the Beta function:</p><p>x^(α+1) = x^((α+2)−1)</p><p>Therefore:</p><p>E[X²] = B(α+2,β) / B(α,β)</p><p>After applying the Gamma-function relationships:</p><p>E[X²] = (α(α+1)) / ((α+β)(α+β+1))</p><p>Substitute both formulas:</p><p>Var(X) = (α(α+1))/((α+β)(α+β+1)) − (α/(α+β))²</p><p>Now simplify.</p><p>The result is:</p><p>Var(X) = αβ / [(α+β)²(α+β+1)]</p><p><strong>Question</strong></p><p>Suppose we are studying the conversion rate of a website. We choose:</p><p>α=6, β=4</p><p>So,</p><p>X ~ Beta(6,4)</p><p>The mean is:</p><p>E[X] = 6/(6+4) = 0.6</p><p>So the mean conversion rate is 60%.</p><p>The variance is:</p><p>Var(X) = 6(4) / [(6+4)²(6+4+1)] ≈ 0.0218</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from scipy.stats import beta</pre><pre># Parameters<br>alpha = 6<br>beta_param = 4</pre><pre># x values between 0 and 1<br>x = np.linspace(0, 1, 500)</pre><pre># Beta PDF<br>pdf = beta.pdf(x, alpha, beta_param)</pre><pre># Mean<br>mean = alpha / (alpha + beta_param)</pre><pre># Variance<br>variance = (<br>    alpha * beta_param<br>    / ((alpha + beta_param)**2 *<br>       (alpha + beta_param + 1))<br>)</pre><pre>print(&quot;Mean:&quot;, mean)<br>print(&quot;Variance:&quot;, variance)</pre><pre># Visualization<br>plt.figure(figsize=(8, 5))</pre><pre>plt.plot(x, pdf, label=&quot;Beta PDF&quot;)</pre><pre>plt.axvline(<br>    mean,<br>    linestyle=&quot;--&quot;,<br>    label=f&quot;Mean = {mean:.2f}&quot;<br>)</pre><pre>plt.xlabel(&quot;Conversion Rate&quot;)<br>plt.ylabel(&quot;Probability Density&quot;)<br>plt.title(&quot;Beta Distribution: Website Conversion Rate&quot;)</pre><pre>plt.legend()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*NAX7Ra8QOLWV0CoIlS1mXA.png" /></figure><p>Here is the summary table for you all:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*qnSR34GKRozwvDxQQrQnvQ.png" /></figure><p>So far we have come a long way unfolding <strong>Probability Distributions</strong>. And nothing gives me more pleasure than seeing people find my blogs helpful. So just to let you know I feel so grateful if you really liked my blog or this helped you in any way.</p><p>My next trajectory will go toward <strong>Sampling and Inferential Foundations</strong>. We will cover some important topics under it. Till then <em>HAPPY LEARNING</em>.</p><h3>Resources</h3><ul><li><a href="https://github.com/MansiBramta/Continuous_Probability_Distributions"><strong>GitHub Repository</strong></a></li><li><a href="https://www.kaggle.com/code/mansibramta/continuous-probability-distributions"><strong>Kaggle Notebook</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=020ca3d8901e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bernoulli Asked “Success or Failure.” Poisson Asked “How Many?]]></title>
            <link>https://medium.com/@mansibramta12/bernoulli-asked-success-or-failure-poisson-asked-how-many-760e0b36f5d2?source=rss-4e5a6b578be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/760e0b36f5d2</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[probability]]></category>
            <dc:creator><![CDATA[Mansi Bramta]]></dc:creator>
            <pubDate>Fri, 18 Sep 2026 15:28:20 GMT</pubDate>
            <atom:updated>2026-09-18T15:56:21.661Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gJJg-P77cSyyxtzEhKz-MA.png" /></figure><h4>Understanding six common discrete probability distributions through the questions they answer</h4><p>In my previous blog, I have talked about some basic topics which add up to this article. Without going into depth, I will touch the surface once again to keep the flow. So, if you haven’t gone through the previous blog, I would highly recommend going through it once, or for now, bear with me.</p><p>Let us segregate <em>“Discrete Probability Distributions”</em> first.</p><p>In my last blog, “PMF, PDF &amp; CDF: Three Ways Probability Helps Us Understand Data”, I introduced you to the concept of a <strong>Random Variable</strong>. A whole discussion was done around it. Let us revise it once again with an example we took earlier:</p><p>Tossing an unbiased coin gives us the outcomes <em>H</em> and <em>T</em>. If we take <em>X = H → 1</em> and <em>X = T → 0</em>, then <em>X</em> becomes a <strong>Random Variable</strong>.</p><p>And the probability for each will be 0.5 as it is an unbiased coin. So, if you want me to give you a proper definition for <strong>Probability Distributions</strong>, it will be:</p><p><strong>A probability distribution is a mathematical way of describing how probability is spread across the possible values of a random variable.</strong></p><p>Also we had a good discussion around <em>Discrete</em> and <em>Continuous</em> random variables in my same blog. That naturally connects here, as <strong>Discrete Probability Distributions</strong> are used when the random variable takes countable values. Which sums up to something like <em>X = {0,1,2…}</em>. All the values of <em>Random Variable</em> are <em>Discrete</em> in nature.</p><p><strong>But why do we need it?</strong></p><p>That’s a valid question, isn’t it? We are talking about this so that we can get a clear structure to work on. How likely is the 0 value? What about 1 and so on, i.e.</p><p><em>X</em> → <em>Probability</em></p><p>0 → 0.5</p><p>1 → 0.5</p><p>We also learned that while dealing with Discrete Random Variables, we use the <strong>Probability Mass Function</strong>. This gives us a <strong>Discrete Probability Distribution</strong>.</p><p>A valid PMF must satisfy two conditions:</p><ol><li>Probability cannot be negative</li><li>All probabilities must add up to 1</li></ol><p>In simple words, for a large number of experiments, it gives us a mathematical rule to calculate the probability:<em>”Probability Mass function(PMF)”</em>.</p><p>After this, it might naturally occur to us that there is one single <strong>Discrete Probability Distribution</strong>, but that’s not the case. There are several important distributions, each designed for a particular type of random experiment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aSlhSYIcGWWFbSSbs0thZA.png" /></figure><p>Let’s start with</p><p><strong>1. Bernoulli Distribution</strong> :</p><p>The Bernoulli distribution is named after <strong>Jacob Bernoulli</strong> (1655–1705), a Swiss mathematician who studied probability and repeated experiments with two possible outcomes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*nORmW_2BWDjI0-2d8uGMbA.jpeg" /></figure><p>While tossing a coin, we are dealing with two possible outcomes: ‘<em>Head (H)</em>’ and ‘<em>Tail (T)</em>’. If <em>X = 1 → H</em> and <em>X = 0 → T</em> then <em>P(X = 1) = p</em> and <em>P(X = 0) = 1 — p</em>.</p><p>Then the <em>PMF</em> becomes</p><p>P(X=x) = pˣ(1−p)¹⁻ˣ ,x∈{0,1}</p><p>The key idea here is to remember <em>what are we doing in a single trial with two possible outcomes</em>.</p><p>The general formula for the <strong>expected value</strong> of a discrete random variable is:</p><p>E[X] = ∑ₓ x·P(X = x)</p><p>For a Bernoulli random variable, the value of (X) can be either 0 or 1.</p><p>so the Mean becomes :</p><p>E[X] = 0·P(X=0)+1·P(X=1)</p><p>E[X] = 0·(1−p)+1·(p)</p><p>E[X] = p</p><pre>Mean --&gt; Probability of Success</pre><p>and Variance becomes :</p><p>Var(X) = E[X²] − (E[X])²</p><p>Since X can only be 0 or 1:</p><p>X² = X</p><p>0² = 0</p><p>1² = 1</p><p>Therefore:</p><p>E[X²] = E[X] = p</p><p>Substitute into the variance formula:</p><p>Var(X) = p − p²</p><p>Var(X) = p(1−p)</p><p><em>Variance is 0 for values of (p = 0,1), but maximum at (p = 0.5).</em></p><pre>*max Var(X)=0.25​*</pre><p><strong>2. Binomial Distribution</strong> :</p><p>Now what if I toss a coin one time and want to do it again? And again? And again, for a fixed number of times. Then what ? Repeating Bernoulli trials again and again gives us the <em>Binomial Distribution</em>.</p><p>Asking something like <em>Toss a coin 10 times. How many heads will we get?</em> On tossing coin 10 times it is possible we do not get head in any flip or what if we got head in all or in some i.e</p><p>X = number of heads</p><p>Possible values:</p><p>X ∈ {0,1,2,…,10}</p><p>This is a <strong>Binomial distribution</strong>.</p><p>The PMF is:</p><p>P(X = k) = C(n,k) · pᵏ(1−p)ⁿ⁻ᵏ</p><p>where:</p><p>(n) = number of trials</p><p>(k) = number of successes</p><p>(p) = probability of success</p><p>Binomial is simply the number of successes across (n) independent Bernoulli trials. Therefore,</p><p>Mean:</p><p>E[X] = np</p><p>Variance:</p><p>Var(X) = np(1 − p)</p><p>Here the important thing to mention is the events performed should be independent of each other. Suppose if</p><p>X = X1​+X2​</p><p>The general formula is:</p><p>Var(X1+X2) = Var(X1) + Var(X2) + 2Cov(X1,X2)</p><p>For independent trials:</p><p>Cov(X1,X2) = 0</p><p>Therefore:</p><p>Var(X1+X2) = Var(X1) + Var(X2)</p><p>For (n) independent Bernoulli trials:</p><p>Var(X) = np(1−p)</p><p>But if the trials were dependent, we couldn’t simply use that formula.</p><p>This is one reason the assumptions of a distribution matter.</p><p><strong>3. Multinomial Distribution</strong> :</p><p>It has the same foundation as the <em>Binomial Distribution</em>, but the key difference, as suggested by the name Multinomial, is that above we were dealing with <em>success (1)</em> or <em>failure (0)</em>, but here we have more than two categories. On rolling a die, we have 6 possible outcomes per trial and count each category. We are still working with a number of trials, but not with just two possible outcomes, hence making it a <strong>Multinomial Distribution</strong>.</p><p>The PMF is</p><p>P(X₁=x₁, …, Xₖ=xₖ) = [n! / (x₁!x₂!⋯xₖ!)] · p₁^x₁ p₂^x₂ ⋯ pₖ^xₖ​​</p><p>where</p><p>x1​ + x2​ + ⋯ + xk ​ = n.</p><p>The counts across all categories must add up to the total number of trials and</p><p>p1​ + p2 ​+ ⋯ + pk​ = 1</p><p>Therefore:</p><p>Multinomial PMF = number of arrangements×probability of each one arrangement</p><p>That’s the intuition behind the formula.</p><p>The idea for <em>Mean</em> and <em>Variance</em> is kinda same just we need to consider category (i),</p><p>Xi = number of times category i occurs.</p><p>Therefore <em>Mean</em>:</p><p>E[Xi] = npi</p><p><em>Variance</em>:</p><p>Var(Xi) = npi(1−pi)</p><p><strong>4. Geometric Distribution</strong> :</p><p>Okay, so till now we were focusing on getting how many successes in a particular number of trials. But what if I only want to do my experiment until I get my first success? I will keep tossing my coin till i get my first head either be it first time or fifth or tenth…</p><p>To get the first success on the (k)-th trial, we need (k-1) failures first, followed by one success. Therefore, PMF is:</p><p>P(X=k) = (1−p)ᵏ⁻¹ · p</p><p>Here, (X) represents the number of trials until the first success.</p><p>Mean:</p><p>For one success, if the probability of success is (p), the expected number of trials is:</p><p>E[X] = 1/p</p><p>smaller p ⇒ longer waiting time</p><p>Variance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*tN0SFtJFaAkbLEkVFdayog.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/1*PiGthtHAcG1dOdglgqym-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*gnzRqWQ_QnlY-S0TLYJ0mw.png" /></figure><p>Hence, finally we got:</p><p>Var(X) = (1−p)/p²​</p><p>So when success becomes rare, not only do we wait longer, but the waiting time becomes much more unpredictable.</p><p>That’s why the variance grows rapidly as (p) becomes small.</p><p><strong>5. Negative Binomial Distribution</strong> : In a similar fashion, above we went for the first success, and now I want the (r)-th success, so we go for the <strong>Negative Binomial Distribution</strong>.</p><p><em>PMF</em> is :</p><p>P(X=k) = C(k−1, r−1) · pʳ(1−p)ᵏ⁻ʳ</p><p>provided (X) means number of trials until the (r)-th success.</p><p>where (k≥r)</p><pre>Geometric is a special case of the Negative Binomial when r = 1.</pre><p>Now let us discuss where this came from.</p><p>Let <em>X</em> be the number of trials to get r-th success. Now the question is <em>what is the probability of getting success exactly at k-th trial?</em></p><p>For this, the (k)-th position should have the (r)-th success, and the first (k-1) positions must contain (r-1) successes, so therefore (k−1)−(r−1) = k−r failures.</p><p>Which gives us pʳ(1−p)ᵏ⁻ʳ</p><p>But this is not yet the PMF. The trials before the final success can be arranged in different ways, which is why we need the combination term:</p><p>C(k−1, r−1)</p><p>Combining all gives us the PMF of Negative Binomial Distribution i.e</p><p>P(X=k) = C(k−1, r−1) · pʳ(1−p)ᵏ⁻ʳ</p><p>Now let us learn about mean and variance in depth.</p><p>Mean:</p><p>For one success, if the probability of success is (p), the expected number of trials is:</p><p>E[X] = 1/p</p><p>For r successes we need to add this r times, giving us :</p><p>E[X] = r/p​</p><p>​Variance:</p><p>same goes for the variance adding up r times resulting in :</p><p>Var(X) = r(1−p/p2)</p><p><strong>6. Poisson Distribution</strong> :</p><p>The Poisson distribution is named after the French mathematician and physicist <strong>Siméon Denis Poisson</strong>, who introduced the concept in his 1837 work on probability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/183/1*b9E6Weu4b3tlEzB4nCBgrw.jpeg" /></figure><p>Poisson is the most interesting one out of all because it is not giving us the number of successes in trials, nor telling us when we will get our first or (r)-th success. It is asking a totally different question.</p><p><em>“It is counting how many times an event takes place in a fixed interval of time, space, area, etc.”</em></p><p>Its PMF is:</p><p>P(X=k) = (e^−λ · λᵏ) / k!</p><p>where:</p><p>(k) = number of events</p><p>(λ) = average number of events in the interval</p><p>The Poisson model assumes that events occur independently and at a constant average rate over the interval.</p><p>Now the thing is how we landed up here? Recall the Binomial PMF :</p><p>P(X=k) = C(n,k) · pᵏ(1−p)ⁿ⁻ᵏ</p><p>This is calculating probability of exactly k successes in n trials.</p><p>To derive Poisson, imagine dividing one minute into (n) very tiny intervals.</p><p>If the average number of events per minute is (λ), then, after dividing one minute into (n) very small intervals, the probability of an event in each interval is approximately</p><p>p = λ/n​</p><p>substituting this into <strong>Binomial PMF</strong> gives:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*Geeb8DcfFWzUbl5W9wkKDw.png" /></figure><p>The most interesting thing to see mathematically here is the</p><p><strong>Mean = Variance = λ</strong></p><p>Let’s see how it came part by part:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*pRbsG0Duq9-h8hZ-KK4f0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*3WiIswVg_k4SsWPJl-pw9g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/1*AGzw7TY3S1UweGonWTkgeg.png" /></figure><h3>Practice Questions:</h3><p>Question: A biased coin has a probability of 0.6 of landing on heads. If the coin is tossed once, let X = 1 if the outcome is heads and X = 0 if the outcome is tails.</p><p>Find:</p><ol><li>The PMF of X.</li><li>The mean and variance of X.</li></ol><p>Solution :</p><p>Since there are only two possible outcomes, X follows a Bernoulli distribution with parameter p = 0.6.</p><ol><li>PMF</li></ol><p>The PMF of a Bernoulli random variable is:</p><p>P(X=x) = pˣ(1−p)¹⁻ˣ ,x∈{0,1}</p><p>Substituting p = 0.6:</p><p>P(X=x) = 0.6ˣ(1−0.6)¹⁻ˣ</p><p>For <em>X</em> = 0:</p><p>P(X=0) = 0.4</p><p>For <em>X</em> = 1 :</p><p>P(X=1) = 0.6</p><ol><li>Mean</li></ol><p>The expected value of a Bernoulli random variable is:</p><p>E[X] = p</p><p>Therefore:</p><p>E[X] = 0.6</p><ol><li>Variance</li></ol><p>The variance is:</p><p>Var(X) = p(1−p)</p><p>Substituting p = 0.6:</p><p>Var(X) = 0.6(0.4)</p><p>Var(X) = 0.24</p><pre>from scipy.stats import bernoulli</pre><pre># parameter for the distribution<br>p = 0.6</pre><pre>#  create bernoulli distribution<br>X = bernoulli(p)</pre><pre># pmf<br>print(&quot;P(X=0):&quot;,X.pmf(0))<br>print(&quot;P(X=1):&quot;,X.pmf(1))</pre><pre># mean<br>print(&quot;Mean:&quot;,X.mean())</pre><pre># variance<br>print(&quot;Variance:&quot;,X.var())</pre><p>Question: A factory produces electronic components, and historical data shows that 10% of the components are defective. A quality-control engineer randomly selects 8 components independently.</p><p>Let X represent the number of defective components among the 8 selected components.</p><p>Find:</p><ol><li>The PMF of X.</li><li>The probability that exactly 2 components are defective.</li><li>The mean and variance of X.</li></ol><p>Solution:</p><p>This is a Binomial Distribution because:</p><p>There is a fixed number of trials: n=8.</p><p>Each trial has two possible outcomes: defective or non-defective.</p><ol><li>PMF of the Binomial Distribution</li></ol><p>The PMF is:</p><p>P(X=k) = C(n,k) · pᵏ(1−p)ⁿ⁻ᵏ</p><p>where k = 0,1,…,n.</p><p>Substituting n = 8 and p = 0.1:</p><p>P(X=k) = C(8,k) · (0.1)ᵏ(0.9)⁸⁻ᵏ</p><ol><li>Probability of exactly 2 defective components</li></ol><p>We need to find:</p><p>P(X=2) = C(8,2) · (0.1)²(0.9)⁶</p><p>P(X=2) = 28(0.01)(0.531441)</p><p>P(X=2) = 0.14880348</p><p>So, the probability of exactly 2 defective components is approximately 14.88%.</p><ol><li>Mean and variance</li></ol><p>For a Binomial Distribution:</p><p>E[X] = np</p><p>E[X] = 8(0.1)</p><p>E[X] = 0.8</p><p>The variance is:</p><p>Var(X) = np(1−p)</p><p>Var(X) = 8(0.1)(0.9)</p><p>Var(X) = 0.72</p><pre>from scipy.stats import binom</pre><pre># parameters<br>n = 8<br>p = 0.1</pre><pre># create binomial distribution <br>X = binom(n,p)</pre><pre># PMF<br>print(&quot;P(X=2):&quot;,X.pmf(2))</pre><pre>#mean<br>print(&quot;Mean:&quot;,X.mean())</pre><pre># Variance<br>print(&quot;Variance:&quot;,X.var())</pre><p>Question : A survey asks 10 customers which of three payment methods they prefer:</p><p>Cash: probability (p_1=0.5)</p><p>Card: probability (p_2=0.3)</p><p>UPI: probability (p_3=0.2)</p><p>Assume each customer’s choice is independent.</p><p>Let:</p><p>(X_1) = number of customers choosing Cash</p><p>(X_2) = number of customers choosing Card</p><p>(X_3) = number of customers choosing UPI</p><p>Find:</p><ol><li>The probability that 5 customers choose Cash, 3 choose Card, and 2 choose UPI.</li><li>The mean and variance of the number of customers choosing each payment method.</li></ol><p>Solution :</p><p>This is a Multinomial Distribution because:</p><p>There is a fixed number of trials: (n=10).</p><p>Each trial can have more than two possible categories.</p><ol><li>Probability of 5 Cash, 3 Card and 2 UPI</li></ol><p>PMF is:</p><p>P(X₁=x₁, X₂=x₂, X₃=x₃) = [n! / (x₁!x₂!x₃!)] · p₁^x₁ p₂^x₂ p₃^x₃</p><p>P(X₁=5, X₂=3, X₃=2) = [10! / (5!3!2!)] · (0.5)⁵(0.3)³(0.2)²</p><p>10! / (5!3!2!) = 2520</p><p>P(X₁=5, X₂=3, X₃=2) = 2520 · (0.5)⁵(0.3)³(0.2)²</p><p>P(X₁=5, X₂=3, X₃=2) = 0.08505</p><ol><li>Mean and variance</li></ol><p>For each category (i), the mean is:</p><p>E[Xi] = npi​</p><p>Cash</p><p>E[X1] = 10(0.5) = 5</p><p>Card</p><p>E[X2] = 10(0.3) = 3</p><p>UPI</p><p>E[X3] = 10(0.2) = 2</p><p>The variance of each category is:</p><p>Var⁡(Xi) = npi(1−pi)</p><p>So:</p><p>Cash:</p><p>Var⁡(X1) = 10(0.5)(0.5) = 2.5</p><p>Card:</p><p>Var⁡(X2) = 10(0.3)(0.7) = 2.1</p><p>UPI:</p><p>Var⁡(X3) = 10(0.2)(0.8) = 1.6</p><pre>from scipy.stats import multinomial</pre><pre># Parameters<br>n = 10<br>p = [0.5, 0.3, 0.2]</pre><pre># Counts for each category<br># Cash = 5, Card = 3, UPI = 2<br>x = [5, 3, 2]</pre><pre># Create the Multinomial distribution<br>X = multinomial(n, p)</pre><pre># PMF<br>probability = X.pmf(x)</pre><pre># Mean<br>mean = [n * pi for pi in p]</pre><pre># Variance<br>variance = [n * pi * (1 - pi) for pi in p]</pre><pre># Print results<br>print(&quot;Probability:&quot;, probability)</pre><pre>print(&quot;\nMean:&quot;)<br>print(&quot;Cash:&quot;, mean[0])<br>print(&quot;Card:&quot;, mean[1])<br>print(&quot;UPI:&quot;, mean[2])</pre><pre>print(&quot;\nVariance:&quot;)<br>print(&quot;Cash:&quot;, variance[0])<br>print(&quot;Card:&quot;, variance[1])<br>print(&quot;UPI:&quot;, variance[2])</pre><p>Question : A basketball player has a probability of (0.4) of making a free throw.</p><p>She keeps taking free throws until she makes her first successful shot.</p><p>Let (X) be the number of attempts required to get the first success.</p><p>Find:</p><ol><li>The probability that her first successful shot occurs on the 4th attempt.</li><li>The mean and variance of (X).</li></ol><p>Solution :</p><p>This is a Geometric Distribution because:</p><ol><li>Each trial has two outcomes: success or failure.</li><li>We are interested in the number of trials until the first success.</li></ol><p>The PMF is:</p><p>P(X=k) = (1−p)ᵏ⁻¹ · p</p><p>For (k=4):</p><p>P(X=4) = (1−0.4)3(0.4)</p><p>P(X=4) = (0.6)3(0.4)</p><p>P(X=4) = 0.0864</p><p>Mean</p><p>E[X] = 1/p</p><p>E[X] = 10.4</p><p>E[X] = 2.5</p><p>Variance</p><p>Var⁡(X) = (1−p)/p2​</p><p>Var⁡(X) = 0.60</p><p>Var(X)=3.75</p><pre>from scipy.stats import geom</pre><pre># Parameter<br>p = 0.4</pre><pre># Create Geometric distribution<br>X = geom(p)</pre><pre># Probability that first success occurs on 4th attempt<br>probability = X.pmf(4)</pre><pre># Mean<br>mean = X.mean()</pre><pre># Variance<br>variance = X.var()</pre><pre># Print results<br>print(&quot;P(X=4):&quot;, probability)<br>print(&quot;Mean:&quot;, mean)<br>print(&quot;Variance:&quot;, variance)</pre><p>Question : A salesperson has a probability of (0.3) of making a successful sale on each independent customer interaction.</p><p>She continues approaching customers until she makes her 3rd successful sale.</p><p>Let (X) represent the number of customers approached until the 3rd success.</p><p>Find:</p><ol><li>The probability that the 3rd successful sale occurs on the 8th customer.</li><li>The mean and variance of (X).</li></ol><p>Solution :</p><p>This is a Negative Binomial Distribution because:</p><ol><li>Each trial has two outcomes: success or failure.</li><li>We continue until we obtain a fixed number of successes, here (r=3).</li></ol><p>The PMF is:</p><p>P(X=k) = C(k−1, r−1) · pʳ(1−p)ᵏ⁻ʳ</p><p>For (k=8) and (r=3):</p><p>P(X=8) = (72)(0.3)3(0.7)5</p><p>P(X=8) ≈ 0.09529569</p><ol><li>Mean and Variance :</li></ol><p>Mean :</p><p>For the version where (X) represents the number of trials until the (r)-th success:</p><p>E[X] = rp​</p><p>E[X] = 30.3​</p><p>E[X] = 10</p><p>Variance</p><p>Var⁡(X) = r(1−p)/p²</p><p>Var⁡(X) = 3(0.7)0.32</p><p>Var(X) = 23.3333</p><pre>from scipy.stats import nbinom</pre><pre># Parameters<br>r = 3<br>p = 0.3</pre><pre># Create Negative Binomial distribution<br>X = nbinom(r, p)</pre><pre># Probability that the 3rd success occurs on the 8th trial<br># SciPy counts the number of failures before the r-th success.<br># Therefore, 8 trials means 8 - 3 = 5 failures.<br>probability = X.pmf(8 - r)</pre><pre># Mean number of failures before the r-th success<br>mean_failures = X.mean()</pre><pre># Variance of number of failures<br>variance_failures = X.var()</pre><pre># Convert mean to number of trials<br>mean_trials = mean_failures + r</pre><pre># Variance remains the same<br>variance_trials = variance_failures</pre><pre># Print results<br>print(&quot;P(X=8):&quot;, probability)<br>print(&quot;Mean number of trials:&quot;, mean_trials)<br>print(&quot;Variance:&quot;, variance_trials)</pre><p>we can see above in the code, the code seems different then what we have discussed but why is it different ? Above we discussed:</p><p>X = number of trials until the (r)-th success</p><p>but in SciPy’s nbinom:</p><p>X = number of failures before the (r)-th success</p><p>If the 3rd success happens on trial 8, then among the first 7 trials, there must be:</p><p>2 successes 5 failures</p><p>And trial 8 must be the 3rd success.</p><p>So:</p><p>8−3 = 5</p><p>There are 5 failures.</p><p>That’s why the code says:</p><pre>probability = X.pmf(8 - r)</pre><p>which becomes:</p><pre>probability = X.pmf(5)</pre><p>By the time the experiment ends at the 3rd success, there are exactly (r=3) successes.</p><p>Therefore:</p><p>trials = failures + 3</p><p>So:</p><pre>mean_trials = mean_failures + r</pre><p>gives:</p><p>7 + 3 = 10</p><p>Question : A customer-support center receives an average of 4 calls per hour.</p><p>Assume that calls occur independently and the average rate remains constant.</p><p>Let (X) represent the number of calls received in one hour.</p><p>Find:</p><ol><li>The probability of receiving exactly 6 calls in one hour.</li><li>The mean and variance of (X).</li></ol><p>Solution :</p><p>This is a Poisson Distribution because we are counting the number of events occurring within a fixed interval of time, and we know the average rate of occurrence.</p><ol><li>The PMF is:</li></ol><p>P(X=k) = (e^−λ · λᵏ) / k!​</p><p>For exactly 6 calls:</p><p>P(X=k) = (e^−4 · 4⁶) / 6!</p><p>P(X=6) ≈ 0.104196</p><ol><li>Mean and Variance:</li></ol><p>Mean:</p><p>For a Poisson distribution:</p><p>E[X] = λ</p><p>Therefore:</p><p>E[X] = 4</p><p>Variance:</p><p>For Poisson:</p><p>Var⁡(X) = λ</p><p>Therefore:</p><p>Var(X) = 4</p><pre>from scipy.stats import poisson</pre><pre># Parameter<br>lambda_value = 4</pre><pre># Create Poisson distribution<br>X = poisson(lambda_value)</pre><pre># Probability of exactly 6 calls<br>probability = X.pmf(6)</pre><pre># Mean<br>mean = X.mean()</pre><pre># Variance<br>variance = X.var()</pre><pre># Print results<br>print(&quot;P(X=6):&quot;, probability)<br>print(&quot;Mean:&quot;, mean)<br>print(&quot;Variance:&quot;, variance)</pre><p>At last I want to close the blog with a helpful short summary table for you all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*uL5X_sBGAgCTLSMqumJQBA.png" /></figure><p>In this section, we learned about <strong>Discrete Probability Distributions</strong>, and in the further blog, I will be discussing <strong>Continuous Probability Distributions</strong>.</p><h3>Code &amp; Notebook</h3><p>You can find the code and supporting material for this article on GitHub:</p><p><a href="https://github.com/MansiBramta/Discrete_Probability_Distributions"><strong>GitHub Repository</strong></a></p><p>You can also explore and run the examples interactively on Kaggle:</p><p><a href="https://www.kaggle.com/code/mansibramta/discrete-probability-distributions"><strong>Kaggle Notebook</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=760e0b36f5d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PMF, PDF & CDF: Three Ways Probability Helps Us Understand Data]]></title>
            <link>https://medium.com/@mansibramta12/pmf-pdf-cdf-three-ways-probability-helps-us-understand-data-fc23ede41c9a?source=rss-4e5a6b578be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc23ede41c9a</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mansi Bramta]]></dc:creator>
            <pubDate>Fri, 04 Sep 2026 05:27:02 GMT</pubDate>
            <atom:updated>2026-09-04T05:27:02.303Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EctW2w7KM6jShQOTUm2QAg.png" /></figure><h4>From random variables and probability to understanding discrete and continuous data</h4><p>We have gone through “Descriptive Statistics” in Phase-1 and now we are moving forward with “Probability Distributions”. Without making any assumptions that you are familiar with probability, I want to take the initiative to start from the very basics and then I’ll move towards my main topic of interest.</p><p>So very basic question <em>“What is Probability?”</em> You might already know that it is — the numerical measure of how likely an event is to occur. For example going with a very basic example of tossing an unbiased coin. So while tossing a coin we already know there could be two possible <strong>Outcomes</strong>: <em>Head (H)</em> and <em>Tail (T)</em> right?, But do we know what will come while tossing a coin? ‘No’. So this type of event is called <strong>Random Experiment</strong> . <em>Random</em> because we do not know exactly what result will we get and <em>Experiment</em> in probability means a process that produces an uncertain outcome.</p><p>So if we look at all the possible outcomes, we are actually looking at <strong>Sample Space</strong> denoted standardly as <strong>S</strong> i.e <em>S = {H,T}</em>.</p><p>If I say we do not know what will come on coin but I want <em>Head</em>, so all I care about is Head, then it would be called an <strong>Event</strong>. (<em>what outcome are we interested in</em>)</p><p><strong>Probability = Number of favourable outcomes / Total number of possible outcomes</strong>.</p><p>So <strong>what is the probability of getting Head with an unbiased coin?</strong></p><p><em>P(H) = 1/2 = 0.5</em></p><p>50% chance of getting head. Is it right isn’t it? we have at most two outcomes here so both have 50–50% chance.</p><p>We have different <em>Types of Events in Probability</em> we will have a brief discussion around each of it.</p><ul><li>Simple Event: An event containing exactly one outcome. For example, when tossing a coin, getting Head, <em>A = {H}</em> , is a simple event.</li><li>Compound Event : An event containing two or more outcomes example <em>S = {H,T}.</em></li><li>Certain Event / Sure Event : An event that must happen example rising of moon, that is surely gonna happen so <em>P(A) = 1</em>.</li><li>Impossible Event : An event that cannot happen example getting something else other than head or tail, impossible right? <em>P(A) = 0</em></li><li>Complementary Event : The event that represents everything outside the original event example <em>A = {H}</em> so <em>A’ = {T}</em>.</li><li>Mutually Exclusive Events or Disjoint Events: Two events that cannot occur at the same time example we can not get head and tail at the same time in same coin. Therefore, P(A ∩ B) = 0</li><li>Exhaustive Events : A collection of events is exhaustive when together they cover all possible outcomes of the sample space example <em>A = {H} , B = {T}</em> so <em>A ∪ B = {H,T} = S(Sample Space)</em>.</li><li>Equally Likely Events : Events are equally likely when they have the same probability of occurring example as we saw above <em>P(H) = 0.5 = P(T)</em>.</li><li>Independent Events : Two events are independent when the occurrence of one does not change the probability of the other example while tossing a coin if we get Head at first, it does not affect the outcome when we will toss the coin again either be head or tail <em>P(A ∩ B) = P(A) P(B)</em>.</li><li>Dependent Events : Two events are dependent when the occurrence of one affects the probability of the other example if we have a deck of card and I want ACE and I am not replacing the card I already got so first I had 4 ACE’s but on the next go I will have only 3 so the probability changed.</li><li>Conditional Events : An event considered under the condition that another event has already occurred, written as P(A | B). For example, what is the probability of drawing an Ace given that we already know the card drawn is a Spade?</li><li>Elementary Events : An elementary event is an event containing exactly one outcome of the sample space example {H},{T} both the events separately are elementary event.</li><li>Joint Events : A joint event involves the occurrence of two or more events together. It is represented using the intersection of events, A∩B. For example <em>A = {HH,TT}</em> , <em>B = {HH,TT,HT,TH}</em> so <em>A∩B = {HH,TT}</em></li></ul><p>okay, so we have come so far learning about probability and different terms of it, leaning on it now we can build our main topic. Let us start with introduction to <em>Random Variable</em></p><p>A vague definition of a <em>Random Variable</em> could be: “It is a rule or function that assigns a numerical value to each outcome of a random experiment.”</p><p>For example if we toss an unbiased coin , <em>S = {H,T}</em> we get Head or Tail but what if we want a numerical outcome ? we can define an X where I’ll choose 1 if head comes and 0 if tail comes, then this X is defined as <em>‘Random Variable’</em>. We can remember it as:</p><p><strong>Random Outcomes → Numerical Values</strong></p><p>But can these values be only integers or can we have decimal values as well?</p><p>To answer this we are going to look at different types of <em>‘Random Variable’</em>:</p><ul><li><strong>Discrete Random Variable</strong></li><li><strong>Continuous Random Variable</strong></li></ul><p>Now we are at a point where we know numerical values for each random outcome but what if we want to know how often that value is coming ? That question will be answered by <strong>Probability Distribution</strong>.</p><p>From here onwards we will become clear about <strong>Probability Mass Function (PMF)</strong>, <strong>Probability Density Function</strong>, <strong>Cumulative Distribution Function</strong></p><p>Suppose we tossed two unbiased coins, <em>S = {HH,HT,TT,TH}</em> and we are looking for heads , so our random variable <strong>X = {2,1,0,1}</strong> ,So these are <em>Discrete</em> values hence <strong>Discrete Random Variable</strong> . If we want the probability of getting 1, what will it be?</p><p>we have two 1’s and total 4 outcomes hence <em>P(X = 1) = 2/4 = 1/2</em> ,what about getting 2 <em>P(X = 2) = 1/4</em> and 0? <em>P(X = 0) = 1/4</em>. Also see 1/2 + 1/4 + 1/4 = 4/4 = 1. Total probability should always be 1 and the probability for <strong>Discrete Random Variable</strong> has a name <strong>Probability Mass Function (PMF)</strong>. It is called so because it gives probabilities for individual values.</p><p>What if we apply the same concept for <strong>Continuous Random Variable</strong> ? Suppose in a class I want to find the probability of a certain weight, for example P(X = 60). Someone might actually weigh exactly 60 kg, but for a continuous random variable, the probability of observing one exact value is zero. Instead, we calculate probabilities over a range, such as:</p><p>P(50 &lt; X &lt; 60). P(a &lt; X &lt; b) is represented by the area under the PDF curve between a and b. This is why, for continuous random variables, we use the Probability Density Function and calculate probabilities over ranges.</p><p>Let us compare side by side <em>PMF</em> and <em>PDF</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*5YLsMqZWqAahOF7hwfV56A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*XcpocD0U5QdaFgQJKI_5BQ.png" /></figure><p>Can we see one important thing here? For PDF, we do not have probability along the y-axis, it is <strong>probability density</strong>. Because continuous values can take infinitely many values within an interval, we cannot find the probability at a point we must look for the density around it therefore we ended up taking <strong>probability density</strong> along y-axis. To find the probability we must find the shaded area under the graph. Taller part of the curve means — Values around this region are relatively more concentrated and lower part means — Values around this region are relatively less concentrated.</p><p>We learned that a PMF tells us the probability of individual values for a discrete random variable, while a PDF helps us calculate probabilities over ranges for a continuous random variable. But what if we want to know the probability that a random variable is <strong>less than or equal to a particular value?</strong></p><p>Here comes the <strong>Cumulative Distribution Function</strong>.</p><p>Mathematically: <strong>F(x) = P(X ≤ x)</strong></p><p>For our classic example of <em>two coins</em> we already saw <em>P(X = 1) = 1/2</em>, <em>P(X = 2) = 1/4</em> and <em>P(X = 0) = 1/4</em>. What will be F(0), F(1) and F(2)?</p><p>F(0) = P(X ≤ 0) = 1/4 <em>(Here we do not have any variable less than 0 so we only added the probability of having 0)</em>,</p><p>F(1) = P(X ≤ 1) = 1/4 + 1/2 = 3/4 <em>(Here we have values 0 and 1 so we added the probability of having 1 as well as 0)</em>,</p><p>Similarly for F(2) = P(X ≤ 2) = 1/4 + 1/2 + 1/4 = 4/4 = 1 <em>(Here we have values 0,1 and 2 so we added the probability of having 2, 1 and 0)</em>.</p><pre>PMF gives individual probabilities. CDF keeps adding them together.</pre><p>The same goes for the PDF as well, the CDF represents the total area under the PDF curve from the left up to (x). So for our example if we say F(60) = P(X ≤ 60) we mean <strong>What is the probability that a randomly selected student’s weight is 60 kg or less?</strong></p><p>And that is why the <strong>CDF works for both discrete and continuous random variables.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*4MzqoLNbBc1oUWIwuKtgkQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*926U8eBmPeS4NRFQ8WfBbw.png" /></figure><p>Here we can see how the cumulative probability reaches 1 in both cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*uKmwIMHcVZsbeGfnmM77iQ.png" /></figure><p>Here are the mathematical formulations to remember:</p><p><strong>Probability Mass Function (PMF)</strong> :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/194/1*M-9pp_9PJ6LTNhuHmJV9Cw.png" /></figure><p><strong>Probability Density Function</strong> :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*aAeqqWjqR8GPLhcB5-EO1w.png" /></figure><p><strong>Cumulative Distribution Function</strong> :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*JhB23mniLSYcJQUrcNH9QA.png" /></figure><p>DISCRETE</p><pre>PMF ── cumulative sum ──&gt; CDF<br>PMF &lt;──── difference ───── CDF</pre><p>CONTINUOUS</p><pre>PDF ───── integration ───&gt; CDF<br>PDF &lt;── differentiation ── CDF</pre><h3>Practice Questions:</h3><p>Q1. A data scientist is analyzing the number of customer support tickets raised by customers in one week.</p><p>The data collected from 30 customers is:</p><p>2,1,3,0,2,4,1,2,3,2,2,1,3,0,2,4,1,2,3,2,</p><p>1,0,2,5,3,2,1,4,2,3,1,0,2,5,3,2,1,4,2,3,</p><p>0,2,1,3,2,4,1,2,5,30,2,1,3,2,4,1,2,5,3</p><p>Question:</p><p>Using this data:</p><ul><li>Calculate the Probability Mass Function (PMF) of the number of support tickets.</li><li>Find the probability that a randomly selected customer raised:</li></ul><ol><li>Exactly 2 tickets</li><li>At most 2 tickets</li><li>More than 3 tickets</li></ol><p>--&gt; X ∈ {0,1,2,3,4,5}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/1*Zz4TlXaDtCTLLo15a1SQpA.png" /></figure><ol><li>Exactly 2 tickets</li></ol><p>P(X = 2) = 0.333</p><p>So approximately 33.3% of customers raised exactly 2 tickets.</p><p>2. At most 2 tickets</p><p>“At most 2” means: <em>X</em>≤2</p><p>Therefore:</p><p>P(X ≤ 2) = P(0) + P(1) + P(2)</p><p>= 0.10 + 0.20 + 0.333</p><p>P(X ≤ 2) ≈ 0.633</p><p>3. More than 3 tickets</p><p>“More than 3” means: X &gt; 3</p><p>Therefore:</p><p>P(X &gt; 3) = P(4) + P(5)</p><p>= 0.10 + 0.067</p><p>P(X &gt; 3) ≈ 0.167</p><p>Q2. A company analyzes the time customers spend on its website. Let the continuous random variable (X) represent the time spent on the website (in minutes).</p><p>Suppose the probability density function is estimated as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*k7JMz0OvqvK0L5kIO2W9og.png" /></figure><p>Questions:</p><ol><li>Verify whether this is a valid PDF.</li><li>Find the probability that a randomly selected customer spends between 1 and 3 minutes on the website: P(1 ≤ X ≤ 3)</li><li>Find the probability that a customer spends less than 2 minutes. Find the probability that a customer spends more than 3 minutes. What is the probability that a customer spends exactly 2 minutes?</li></ol><p>→ 1. Since the PDF is non-zero only from (0) to (4):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*p4v97C4KdX26FUYOYVasYA.png" /></figure><p>Therefore, this is a valid PDF.</p><p>2️. For a continuous variable, we calculate probability using the area under the curve:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/277/1*R-t5Rr1WIHxK13FnIRwJ8A.png" /></figure><p>So there is a 50% probability that a customer spends between 1 and 3 minutes on the website.</p><p>3️. Probability of spending less than 2 minutes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*tnn97y7u59HwuJjX_V41Eg.png" /></figure><p>So there is a 25% probability that a customer spends less than 2 minutes on the website.</p><p>4️. Probability of spending more than 3 minutes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*Ds_fi5C_6QnK9q_xX55EhQ.png" /></figure><p>So there is a 43.75% probability that a customer spends more than 3 minutes on the website.</p><p>5️. Probability of exactly 2 minutes</p><p><strong>Here’s the most important difference between PMF and PDF:</strong></p><p>P(X = 2) = 0</p><p>Because (X) is a continuous random variable.</p><p>We calculate probabilities over an interval, not at a single point.​</p><p>Until now, we have learned about Probability, Random Variables, PMF, PDF, and CDF. At this point, you might be wondering: Why does a Data Scientist need to learn all of this?</p><p>The answer is simple: data is uncertain.</p><p>When we collect real-world data, we don’t always know exactly what value will appear next. We can observe patterns, understand how values are distributed, and estimate how likely different outcomes are.</p><p>This is where probability becomes important.</p><p>PMF helps us understand probabilities associated with discrete values, while PDF helps us understand how continuous values are distributed. CDF helps us understand the probability of observing a value less than or equal to a particular point.</p><p>These concepts give us the mathematical foundation for understanding uncertainty and patterns in data.</p><p>And as we move further into Probability Distributions and eventually Machine Learning, you will see that these ideas don’t disappear — they become the foundation on which many statistical and Machine Learning concepts are built.</p><p>So don’t worry if the Machine Learning connection isn’t completely visible yet. Right now, we are building the foundation. And just like we cannot build a house without its foundation, we cannot properly understand many Machine Learning concepts without understanding probability first.</p><p><strong>Code &amp; Resources</strong></p><p>You can find the complete Python code, examples, and files used in this article on GitHub:</p><p><a href="https://github.com/MansiBramta/PMF_PDF_CDF">GitHub Repository</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc23ede41c9a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When Bigger Variation Doesn’t Mean More Variability]]></title>
            <link>https://medium.com/@mansibramta12/when-bigger-variation-doesnt-mean-more-variability-5012d4e577fe?source=rss-4e5a6b578be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5012d4e577fe</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Mansi Bramta]]></dc:creator>
            <pubDate>Wed, 19 Aug 2026 17:10:11 GMT</pubDate>
            <atom:updated>2026-08-19T17:10:11.191Z</atom:updated>
            <content:encoded><![CDATA[<h4>Understanding the difference between absolute and relative dispersion through Standard Deviation and Coefficient of Variation.</h4><p>Till now, we have gone through Central Tendencies and then Dispersion. When <strong>Mean</strong>, <strong>Median</strong>, and <strong>Mode</strong> were enough to explain so much about the data, why did we need <strong>Range</strong>, <strong>Variance</strong>, <strong>Standard Deviation</strong>, and <strong>IQR</strong>? To know more, right?</p><p>The current stage always feels enough until you know about <em>what it tells us → what it doesn’t tell us → what additional measure helps us answer that question</em>.</p><p>In the search for more, we are here with a new topic of discussion <strong>Coefficient of Variation</strong>.</p><p>No, we are not getting off from our earlier topic, <em>Dispersion</em>. Rather, I would say we are going to see it from a different perspective — a perspective that you will definitely appreciate once you learn it.</p><p>My intention is nowhere to make this purely mathematical or statistical, but more like a daily conversational thing that will come more naturally. So, I would request every reader to hold on to it, and I promise we will learn it together like never before.</p><p>So, I want you to look at the line plots first. I will explain later what they are for. Here, I only want us to observe the pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g1JkJ66pVi9pl-OtGrIF6Q.png" /></figure><p>Yes, they look kind of similar, but as we look at the means and the scale of the values, we can see the difference in the data. So, let us look at our data now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*ZP9Cuhw_0HsrtPObSyca8Q.png" /></figure><p>As we already know:</p><p><strong>Mean of A = 516.67</strong></p><p><strong>Mean of B = 1000</strong></p><p>Nothing new, right? We already know how to calculate it.</p><p>So, let us see <strong>Standard Deviation</strong> <em>(Dispersion from the Mean in the same units)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*FEi6fap_UO_nIC7z1wmP2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*s0BQswRz4c1gjstWPFd0Qg.png" /></figure><p>We can see clearly that the SD of B is higher than A, which means B’s values have greater absolute spread around their mean than A’s values.</p><p>Now, we will learn something new <strong>Coefficient of Variation</strong>.</p><p>From above, if I ask you what question <strong>Standard Deviation</strong> is asking, and you have to explain it to a non-statistics person, what would you say?</p><p>Yes,</p><p><em>How much are these numbers moving around the average value?</em></p><p>And if I tell you about <strong>Coefficient of Variation</strong>, it would be,</p><p><em>How much are these numbers moving as compared to their usual size?</em></p><p>At first, it might sound confusing, but we can try to simplify this even more.</p><p>The formula to find the Coefficient of Variation is: <em>(SD/MEAN) * 100</em></p><p>Let us break down this formula.</p><p><em>SD</em> → What is the typical spread?</p><p>But is this a lot as compared to the data itself? That’s why we divide it by the Mean.</p><p>But why <em>Mean</em> and not <em>Median</em> or anything else?</p><p>The answer lies in the formulation itself. <em>SD</em> is calculated from the deviations of observations from the mean. Therefore, <em>CV</em> uses the mean as its reference point. When we want to express that spread relative to the overall level of the data, we use the same reference point, the <strong>Mean</strong>.</p><p>We multiply it by 100 to make it more intuitive and express it as a percentage.</p><p>We can do <em>(SD/MEDIAN) * 100</em> but that is not the standard definition of CV because SD and the mean are mathematically linked, SD measures deviations from the mean, so CV uses the mean as its reference point.</p><p>So, let us find out the CV for our data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/1*t755bjwI41bhBoREkecXCw.png" /></figure><p><em>CV of A &gt; CV of B</em></p><p>But we just saw that <em>SD of A &lt; SD of B</em>.</p><p>Here’s what exactly is happening:</p><p>CV is telling us about the spread, but compared to the usual size of the data.</p><p><em>B</em> has more variation in absolute terms, but <em>A</em> has more variation relative to its average.</p><p>And this is the whole explanation.</p><p>I tried to make this as simple as possible because, going forward into Machine Learning algorithms and Data Science, we should be clear about what these statistical measures actually mean rather than simply applying formulas.</p><p>And now that we know how much the data varies, there is still one question left, <strong>what does that variation actually look like? Is the data evenly distributed around the mean, or is it pulled more towards one side?</strong> Are the values concentrated around the centre, or do they have heavier or lighter tails? This is where our next topic, <strong>Skewness</strong> and <strong>Kurtosis</strong>, comes in. We will move one step beyond simply asking “How much is the data spread?” and start asking “How is the data distributed?” Because sometimes, the amount of variation alone isn’t enough to understand the complete story hidden inside our data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5012d4e577fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Mean Looks the Same. The Data Tells a Different Story.]]></title>
            <link>https://medium.com/@mansibramta12/the-mean-looks-the-same-the-data-tells-a-different-story-03eeb134d051?source=rss-4e5a6b578be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/03eeb134d051</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Mansi Bramta]]></dc:creator>
            <pubDate>Mon, 17 Aug 2026 13:08:23 GMT</pubDate>
            <atom:updated>2026-08-17T13:08:23.871Z</atom:updated>
            <content:encoded><![CDATA[<h4>A pocket-money story about dispersion, outliers, and why the mean isn’t enough.</h4><p>In my last blog, I talked about central tendency through a very personal experience of pocket money. I thought it was a fun way of explaining things through building a story. So, going in the same fashion, I want to talk today about <strong>DISPERSION</strong>.</p><p>As I used to get my pocket money every month, I slowly realised I could save some of it to buy something good for me other than food. I could buy my fav dress or my fav game or something else…</p><p>That is exciting, isn’t it, as a kid? So I started saving money, and I did it for the last two years to realise something I will be taking ahead. So let us first see my data for two years of saving. <em>(The amount is what I saved each month)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*_nbOQaKu7BVdKauD5hdmjw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ckI6iuo8qrLPpZQdRUgp-A.png" /></figure><p>Doesn’t it look so cool? Are you seeing the same thing? What exactly drew my attention? Yes, I am talking about the mean. Both the years have the same mean value, Rs. 341.67. Isn’t it interesting how I have completely different points across the years and still got the same mean?</p><p>But another interesting thing worth noticing here is the spread of my data. Let us have a look:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qFHuuP4kgkVO6ztAmVKOEA.png" /></figure><p>There is no clearer way to see it. In 2022, most of my data is concentrated between Rs. 200 — Rs. 400, contrary to 2023, where the data is more widely spread, with most values lying between Rs. 0 and Rs. 600, while a few observations extend as high as Rs. 1,000.</p><p>I mean, like, isn’t it amazing how data having the same mean, partially creating an illusion of being the same, can be so different? Or, more accurately, have such a difference in spread around the mean or among their points.</p><p>I think we are on the same spot right now, thinking about the same thing: “But how can we measure this dispersion?”</p><p>We have some major ways:</p><ul><li>Range</li><li>Variance</li><li>Standard Deviation</li><li>Interquartile Range (IQR)</li></ul><p>Let us go through them one by one:</p><p>Talking about <strong>RANGE</strong> →</p><p>It is the difference between the minimum and the maximum value of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9M3ifj3g8ecUd7wQ8nU2MQ.png" /></figure><p><em>Range for year 2022</em> = 1000–100 = 900</p><p><em>Range for year 2023</em> = 1000–0 = 1000</p><p>This is what we have learned theoretically, right? But what is the instinct behind it? Let’s unfold it together.</p><p>Range is actually telling us the total width of our data. Like in 2022, the smallest value is Rs. 100 and the largest value is Rs. 1000, so the total range is Rs. 900. Similarly, for 2023, the smallest value is Rs. 0 and the largest value is Rs. 1000, giving us a range of Rs. 1000. It doesn’t necessarily mean every value is Rs. 900 more from the minimum or Rs. 1000 more from every data point. But all the values are lying in this spread or dispersion, which actually can be a misleading perspective. It says the data points lie within the range, but what if they are concentrated in a very small interval and we just have an <em>outlier</em> in the data? It can give us an illusion of what the data actually looks like. So, trusting range alone can potentially be a risk.</p><p>Talking about <strong>VARIANCE</strong> →</p><p>We all kind of know the mathematical formulation of variance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*Q8idDXnvR-WCdp5vWS3UvQ.png" /></figure><p>Before diving into this, I want us to discuss first about <em>Expected value</em> i.e E[X] , Expected value represents the average value of a random variable. For our dataset, it is the mean. Intuitively, you can think of the mean as the balance point of the data, where the deviations above and below the mean balance each other out.</p><p>How we came up with this formula? let us start from the beginning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*_1kTcwrSqQnK-JjARhHqAA.png" /></figure><p>Let us try to understand the very first line of it what it actually means?</p><p>We are taking the difference between each point and the mean, i.e. E[X], and squaring it because we can possibly get negative deviations. For example, −4+4=0, but it doesn’t mean the variance is 0. The values simply cancel each other out. So, we square the deviations to make them positive and then find the average of all the squared deviations, ending up with the given outcome.</p><p>So, wrapping it up, variance is the average of the squared deviations from the mean.</p><p>It is completely okay if you are new to this and have no idea what I just said but trust me it feels so natural once you start understanding it. So if you feel like going through this part again feel free to do so and take your time. We all had struggled through it at some point of our lives.</p><p>But here the point is why we need variance?</p><p>We talked about mean earlier and we looked at both of our data sets, for year 2022 and 2023 as well, where the mean is the same but our data is not the same, so how can we know the difference between the two? The answer is variance. Variance tells us how much our data is spread out around the mean. High variance means the observations are more spread out around the mean, while low variance means they are more concentrated around the mean value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*QsYlkRHFDhVM7_xCQKsnqw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*TeCEQBXU89MiZ8hXFI6CsA.png" /></figure><p>We can see that the variance of year 2023 is more than 2022, which means the data points of year 2023 are more dispersed from the mean value <em>(341.67)</em>.</p><p>But guess what? We don’t always interpret variance directly. What we often use is actually <em>standard deviation</em>. Our next target, and why so? Only because of one problem with variance: as we saw above, the values are squared, which means the units become squared as well. Saying “average pocket money squared” is quite unusual to understand, I guess. So that unfolds to the next topic of discussion.</p><p>Talking about <strong>STANDARD DEVIATION</strong> →</p><p>I swear I will not bother you much with this one.</p><p><em>Standard Deviation</em> is the square root of variance, as simple as that. This is done because it brings the measurement back to the original units of the data.</p><p>So,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*ra_m2rvyRj768FX7QWjlxg.png" /></figure><p>I am giving you the reference image here for standard deviation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*Ygl1ac_aQG-lNP_EaW3gxw.png" /></figure><p>Talking about <strong>Interquartile Range (IQR)</strong> →</p><p>Let us first look what it looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*uFgMQF2G85ituQRh7c0I2A.png" /></figure><p>As we saw above, almost everything was measured around the mean, but IQR is something different. It focuses on the middle 50% of the data rather than the entire dataset.</p><p>The <em>Q2</em> mentioned in the above image is the median. Here, we divide our data into four parts. The first part represents the first 25% of the data. From <em>Q1</em> to <em>Q3</em> is the middle 50% of the data, which shows us how spread out this middle portion is. After <em>Q3</em> is the remaining 25% of the data.</p><p><strong>IQR = Q3 — Q1</strong></p><p>But the question remains the same: why do we need it when we have so many other options like standard deviation and range? Then why IQR?</p><p>The answer is simple. During the calculation of IQR, the dataset is arranged in ascending order, which makes it easier to divide the data into <em>quartiles</em>. While we are focusing on the spread of the middle 50% of our data, extreme values have much less influence on it. This makes IQR a more robust measure of dispersion when outliers are present.</p><p>If we talk about my data arranged in ascending fashion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FISgTgIraG-pmWis-QaZwg.png" /></figure><p>These are called <em>Box Plots</em>, and the lines extending from the box are called <em>whiskers</em>.</p><p>For year 2022 here the <em>Q1</em> = Rs. 200, <em>Q3</em> = Rs. 350 and the Median is Rs. 250.</p><p>so <em>IQR</em> = <em>Q3</em> — <em>Q1</em> = 350 — 200 = 150.</p><p>It means that the middle 50% of your 2022 monthly savings are spread across approximately Rs. 150.</p><p>You can see two points lying outside the upper whisker. These are potential outliers according to the box plot rule.</p><p>Similarly we can see for year 2023 here we have no outliers . <em>Q1</em> = Rs. 100, <em>Q3</em> = Rs. 500 and the Median = Rs. 250.</p><p>Therefore <em>IQR</em> = <em>Q3</em> — <em>Q1</em> = 500 − 100 = Rs. 400.</p><p>Which means the middle 50% of your 2023 monthly savings are spread across approximately Rs. 400.</p><p>Did you notice something?</p><p>The median values for both the years are exactly the same: Rs. 250. Yet we have outliers for 2022 and not for 2023, despite both years having the same maximum value of Rs. 1000. This is because outlier detection depends on the spread and quartiles of the dataset, not simply on how large a value looks.</p><p>Before moving to the end, I would like to mention here the rule of the box plot we have talked about above.</p><p>Meaning, we will look at how we are calculating these <em>Q1</em>, <em>Q3</em> values.</p><p>There is no high-level maths involved in it. We just need to keep in mind that we are dividing our ordered data into four parts. So, for calculating <em>Q1</em>, we look at the left half from the median and find the median of that data. Similarly, for <em>Q3</em>, we look at the right half from the median and find the median of that data. And <em>Q2</em> is already the median itself.</p><p>Note: There are different conventions for calculating quartiles. The values shown above follow the percentile method used by our box plot.</p><p>Okay, so I know there could be a point of confusion in your mind that we kind of did the same thing in range, right? So what is happening?</p><p>I caught you …….</p><p>In range, we are finding the difference between the minimum and maximum values of the data, so it represents the spread of the whole data. But in IQR, we are finding the spread of the middle 50% of the data, not the whole dataset.</p><p>At last, I will conclude my content with an overview.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fzpryO5ZrJFuKEO5wPgEQg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=03eeb134d051" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The mean wasn’t lying. I was asking it the wrong question]]></title>
            <link>https://medium.com/@mansibramta12/the-mean-wasnt-lying-i-was-asking-it-the-wrong-question-dcfdec0d4ffc?source=rss-4e5a6b578be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcfdec0d4ffc</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <dc:creator><![CDATA[Mansi Bramta]]></dc:creator>
            <pubDate>Tue, 11 Aug 2026 14:01:10 GMT</pubDate>
            <atom:updated>2026-08-11T14:01:10.174Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>A story about mean, median, and the mode nobody talks about.</strong></h4><p>As a kid, my biggest joy is when I get that pocket money at the start of the month, and I know now I will be buying all that stuff that I want to eat, but the thing is, I never get a fixed amount. I don’t know why, but it is exciting to predict every time my next pocket money amount. So, looking at my previous money data, which is</p><p><strong>Jan — 500, Feb — 800, March — 800, April — 300, May — 400, June — 200, July — 1000, Aug — 500, Sep — 1500, Oct — 200, Nov — 800</strong></p><p>I wanted to predict what might come in December. But before making any prediction, I needed to understand what my previous data was actually telling me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*sQ-u0-yviblcnZSlybvq-g.png" /></figure><p>As I saw the data, I realised that my memory could remember the data only from Jan to Nov, and it means I have data for only 11 months, so I know my data set is too small to make any prediction. So what possibly could I do to help myself? I cannot do much, but I can at least start with some simple measures of central tendency.</p><p>So, as I look at this graph, I have three options <strong>Mean, Median, Mode</strong> .</p><p>So let’s look at where my mean, median, and mode are visually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*jQHTy5ann-e0yyJY8cSQXg.png" /></figure><p><strong>Mean</strong> shows the average of the data. <strong>Median</strong> is the value that sits right in the middle when we arrange our data in order. With an odd number of observations, we get one middle value; with an even number, we take the average of the two middle values. <strong>Mode</strong> tells us which value occurs most frequently in the data.</p><p>So I thought Mean or Median might give me my answer. I calculated my Mean as</p><p><strong>(500 + 800 + 800 + 300 + 400 + 200 + 1000 + 500 + 1500 + 200 + 800) / 11</strong> = Rs. 636.36 and Median as Rs. 500 .</p><p>Looking at these values, I realised my Mean amount looks kind of odd. I never got approximately ₹600 as my pocket money, and that’s perfectly fine — the mean doesn’t have to be one of the observed values. But then another question came to my mind: why was my mean as high as ₹636.36?</p><p>This made me think twice. Should I go with the Mean or the Median? The Median value looked somehow familiar, but why was the Mean so different?</p><p>To understand what exactly in my data was creating this unusual behaviour, I looked at it again. Everything looked normal, but one thing caught my eye: in Sep, due to my birthday, I got Rs. 1500, which was something that I usually don’t get, so is it the problem or something else?</p><p>I tried finding out by removing Sep’s amount from my data. Also, going into the depth, I found out that an unusually extreme observation like this can be called an <em>outlier</em>. So I decided to see what my data would look like without that observation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*nNZmY_oWcaLvDcDTe0sOdw.png" /><figcaption><em>On removing outlier from my data my mean and median came into harmony</em></figcaption></figure><p>Did you see what I saw?</p><p>I wasn’t going to simply throw September away. The ₹1500 was real — it wasn’t a mistake in my data. It was unusual because of my birthday. So I treated it as a potential outlier and compared what my mean looked like with and without that observation.</p><p><strong>(500 + 800 + 800 + 300 + 400 + 200 + 1000 + 500 + 200 + 800) / 10</strong></p><p>New Mean as Rs. 550 and Median Rs. 500.</p><p>You know my whole perspective got changed I never thought mean could actually be telling us something else. I always thought Mean gave us the average value we could rely on but I cannot believe I was asking the wrong question and all of this happened just because of one value, one outlier. From Rs. 636.36, it dropped to Rs. 550, a much more realistic number, and even my median is somehow agreeing with it.</p><p>From here, I realised that we cannot blindly trust the mean to answer every question about our data. The mean wasn’t wrong. I was asking it the wrong question.</p><p>Does my data have outliers in it? So my mean will tell me a different story…</p><p>At that moment, if the question is still “what is the average?”, Median will come to your rescue. Median is much less sensitive to extreme values than the mean.</p><p>So after all this brainstorming, just for my December pocket money, I came to a conclusion that with this tiny dataset, I might not be able to predict exactly what I will get in December, but I can definitely make a more informed guess based on all the observations. And honestly, that makes me happy because now I at least have an idea of how to plan my list of things I want to eat this month.</p><p>But wait, then what was this Mode for?</p><p>After thinking for a couple of minutes, I realised mode was never in the race. Mean and Median were competing from <strong>“what’s a central, typical value in this data?”</strong> but mode was asking a totally different question <strong>“what’s the amount I get usually?”</strong> And yes, it told me I usually get Rs. 800.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*5pS3phj6mssEn8ga9c-QwA.png" /></figure><p>Looking at my past data, ₹800 is the amount I received most frequently.</p><p>And after that, my whole view of seeing Mean, Median, and Mode together got a new version.</p><p>So, did yours change after reading this?</p><h4><strong>The real takeaway</strong></h4><p>Mean and Median both are trying to compress data into a point. That point can be the same or completely different, and that is just because some extreme values in our data are dragging the mean towards the extremities. That can pull the mean away from what feels like a typical value, while the median is much less sensitive to extreme observations and stays closer to the middle of the data. On the other hand, when we want to know which value occurs most frequently, the mode gives us that answer.</p><p>So, before relying on the mean, we need to understand more about our data and to explore this more, we will move ahead with measures of dispersion — variance, standard deviation, and why ‘average’ alone is never the full picture.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcfdec0d4ffc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>