<?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 Albandari on Medium]]></title>
        <description><![CDATA[Stories by Albandari on Medium]]></description>
        <link>https://medium.com/@ptmtsqqhf?source=rss-8dd40a21de2b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YTyY7ugSsertY2An5qQ2Rw@2x.jpeg</url>
            <title>Stories by Albandari on Medium</title>
            <link>https://medium.com/@ptmtsqqhf?source=rss-8dd40a21de2b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 03:03:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ptmtsqqhf/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[Central Tendency (Average)]]></title>
            <link>https://medium.com/@ptmtsqqhf/central-tendency-average-d2a1ca839939?source=rss-8dd40a21de2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2a1ca839939</guid>
            <dc:creator><![CDATA[Albandari]]></dc:creator>
            <pubDate>Fri, 18 Oct 2024 11:46:36 GMT</pubDate>
            <atom:updated>2024-10-18T12:20:07.148Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*ofW8j9FJ4w9sxHrvpMDb5Q.jpeg" /></figure><h3>Mean (Average)</h3><p><strong>value represent the “center” of a collection of numbers</strong> <br> Formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*vYHcFXE8vjnWMc1K-0BGhA.png" /><figcaption>where xi is each value in the dataset and n is the number of values.</figcaption></figure><p>The example below calculates the mean population for different states using the state dataset.</p><p>Python Code :</p><pre>import pandas as pd<br>import numpy as np<br><br># Load the dataset<br>state = pd.read_csv(&#39;state.csv&#39;)<br><br># three ways to calculate the mean <br><br># 1) Manual calculation <br>sum_x = sum(state[&#39;Population&#39;])<br>n = len(state[&#39;Population&#39;])<br>x_bar = sum_x/n<br>print(&quot;Mean:&quot;, x_bar)<br><br># 2) Using pandas package<br>print(&quot;Mean:&quot;, state[&#39;Population&#39;].mean())<br><br># 3) Using numpy package<br>print(f&quot;Mean:&quot;, np.mean(state[&#39;Population&#39;]))</pre><h3>Weighted Mean (Weighted Averge)</h3><p>is a method of computing an average where some data points contribute more than others</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*A8vVN2XVAvoj-RZMWJCL3w.png" /><figcaption>where wi​ is the weight for each value xi​.</figcaption></figure><p>The example below calculates the weighted mean for the murder rate for different states using the state dataset.</p><p>Python Code :</p><pre># Weighted mean calculation<br>&#39;&#39;&#39;<br>When calculating the average murder rate from multiple states,<br>it&#39;s essential to consider the population sizes,especially if <br>one state has a significantly smaller population than the others.<br>This is because a small population can lead to larger fluctuations<br>in the murder rate, which might skew the overall average.<br>&#39;&#39;&#39;<br><br># 2 ways to calculate weighted mean <br> <br># 1) Manual calculation <br>weighted_mean_manual = sum(state[&#39;Murder.Rate&#39;] * state[&#39;Population&#39;]) / sum(state[&#39;Population&#39;])<br>print(&quot;Weighted Mean:&quot;, weighted_mean_manual)<br><br># 2) Using numpy package<br>weighted_mean_numpy = np.average(state[&#39;Murder.Rate&#39;], weights=state[&#39;Population&#39;])<br>print(&quot;Weighted Mean:&quot;, weighted_mean_numpy)<br><br><br># calculation without considering population size<br>simple_mean_without_weights = np.average(state[&#39;Murder.Rate&#39;])<br>print(&quot;Mean without Weights:&quot;, simple_mean_without_weights)</pre><h3>Important Note</h3><blockquote>When calculating the mean or weighted mean, it is crucial to consider all data points, including zero values. Excluding zero can lead to an inflated average</blockquote><p>small example illustratin the note:</p><h4>Mean example</h4><ul><li>Mean Excluding Zero Value</li></ul><p>X=1,2,3</p><p>mean= (1+2+3) / 3 = 2</p><ul><li>Mean Including Zero Value</li></ul><p>Y=1,0,2,0,3</p><p>mean =(1+0+2+0+3) / 5 =0.83</p><h4>Wighted mean example :</h4><p><em>Calculate the average time you spend exercising four days a week over a month or four weeks. The time you spend exercising on any given day is the data set. The number of days you exercise for an average time is the weight you’ll use.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*RXYPVxrcOq4803c5y8brIg.png" /></figure><ul><li>Weighted Mean Excluding Zero Value:</li></ul><p>Weighted Sum = 20(7) +45(3) +15(4) = 140 + 135 + 60 = 335</p><p><em>The total weight = 7+3+4 = 14</em></p><p>Weighted Mean=<em>335/14 = 23.9</em></p><ul><li>Weighted Mean Including Zero Value:</li></ul><p>Weighted Sum = 20(7) +45(3) +15(4)+2(0) = 140+135+60+0 = 335</p><p><em>The total weight = 7+3+4+2 = 16</em></p><p>Weighted Mean=<em>335/16 = 20.9</em></p><p>This examples clearly shows the impact of including or excluding zero values on both mean and weighted mean calculations.</p><h4>Resource :</h4><p>- <a href="https://www.indeed.com/career-advice/career-development/how-to-calculate-weighted-average">https://www.indeed.com/career-advice/career-development/how-to-calculate-weighted-average</a></p><p>- Practical Statistics for Data Scientists, 2nd Edition By Peter Bruce, Andrew Bruce, Peter Gedeck</p><p>- <a href="https://www.ncl.ac.uk/webtemplate/ask-assets/external/maths-resources/statistics/descriptive-statistics/weighted-averages.html">https://www.ncl.ac.uk/webtemplate/ask-assets/external/maths-resources/statistics/descriptive-statistics/weighted-averages.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2a1ca839939" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>