<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: darrendube</title>
    <description>The latest articles on Forem by darrendube (@darrendube).</description>
    <link>https://forem.com/darrendube</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F395881%2F68f35c16-ed9b-41c9-bc04-63c2f61863e3.jpg</url>
      <title>Forem: darrendube</title>
      <link>https://forem.com/darrendube</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/darrendube"/>
    <language>en</language>
    <item>
      <title>Airline Recovery Post-COVID: What the Data Says</title>
      <dc:creator>darrendube</dc:creator>
      <pubDate>Sun, 29 Jun 2025 21:14:03 +0000</pubDate>
      <link>https://forem.com/darrendube/airline-recovery-post-covid-who-bounced-back-and-why-2i3p</link>
      <guid>https://forem.com/darrendube/airline-recovery-post-covid-who-bounced-back-and-why-2i3p</guid>
      <description>&lt;p&gt;The aviation industry was hit severely by COVID-19 in 2020 and 2021, with demand falling to about a third of what it was pre-pandemic.  In my analysis of airline performance in the post-recovery period of 2022/23, I found that &lt;strong&gt;load factor&lt;/strong&gt; (how full planes were) and &lt;strong&gt;aircraft utilisation&lt;/strong&gt; (how much each plane flew per day) were very strong drivers of profit as measured by Earnings Before Interest and Taxes (EBIT). Additionally, full-service and legacy airlines earned more profit coming out of the pandemic than less established or low-cost airlines. However, this does not imply that full-service or legacy airlines recovered to pre-pandemic profit levels faster than low-cost airlines, as pre-pandemic profit was not controlled for in this analysis.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For the more statistically inclined, you may read my full analysis &lt;a href="https://nbviewer.org/github/darrendube/airline-profitability-analysis/blob/main/notebook.ipynb" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Big profits for full-service airlines - with a caveat
&lt;/h4&gt;

&lt;p&gt;Low-cost carriers earned less profit, on average, than full-service carriers – about $462 million less. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk4vn74p4t1rak5jo5dj9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk4vn74p4t1rak5jo5dj9.png" alt="Image description" width="800" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is important to note that this does not imply that full-service carriers recovered faster than low-cost carriers – this analysis only considered absolute profit levels and did not control for pre-pandemic profit levels. It also does not imply that low-cost airlines were less profitable than full-service airlines – again, because absolute profit levels, not a ratio, were used.&lt;/p&gt;

&lt;h4&gt;
  
  
  Experience Pays
&lt;/h4&gt;

&lt;p&gt;Older airlines earned higher profit: each additional year of age resulted in an airline earning $7 million more. This is after controlling for the airline’s size as measured by the number of routes, and whether the airline was a low-cost carrier. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4awcdnanwoji1x0oouwj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4awcdnanwoji1x0oouwj.png" alt="Image description" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  More routes, more profit?
&lt;/h4&gt;

&lt;p&gt;A 1% increase in an airline’s number of routes was found to decrease profit by a couple of millions of dollars (keeping the other factors in the model constant). In fact, an initially positive relationship (before accounting for any other factors) was found to change to a negative one after controlling for these factors. Factors in the model that may have confounded the initial relationship are load factor (indicating that airlines with more routes may have lower average load factors), and aircraft utilisation (indicating that airlines that overutilised their aircraft may have experienced lower average load factors). As the world was still recovering from COVID in FY 2022/23, it was perhaps the case that certain destinations (e.g. more "ourdoorsy" vacation destinations) were more popular than others, and airlines that better capitalised on this by focusing on those routes could overcome the disadvantage of maintaining a smaller route network than larger airlines.&lt;/p&gt;




&lt;p&gt;The results of this analysis suggest that, overall, operational efficiency (particularly in how often planes flew and how full they were) may have been more important than airline size or type in determining profit. However, this analysis was based on a non-random sample of 100 airlines, restricting the number of statistical tools available in this analysis.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For a more comprehensive explanation and walkthrough of my analysis, click &lt;a href="https://nbviewer.org/github/darrendube/airline-profitability-analysis/blob/main/notebook.ipynb" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Darren Dube - Data Science student at Stellenbosch University. Catch me on &lt;a href="https://linkedin.com/in/darrendube" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Data will never be clean</title>
      <dc:creator>darrendube</dc:creator>
      <pubDate>Sat, 18 Jun 2022 22:44:12 +0000</pubDate>
      <link>https://forem.com/darrendube/data-will-never-be-clean-b93</link>
      <guid>https://forem.com/darrendube/data-will-never-be-clean-b93</guid>
      <description>&lt;p&gt;In 2016, Microsoft released &lt;a href="https://en.wikipedia.org/wiki/Tay_(bot)"&gt;Tay&lt;/a&gt;, an AI chatbot designed to interact with Twitter users, answering their questions, and learning from users' replies. Unlike the other chatbots of the time, however, Tay was meant to have a personality, and to have a sense of humour, engaging in “casual and playful conversation”.&lt;/p&gt;

&lt;p&gt;Yet, in a few hours of release, the conversations were somewhat less “playful”:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UoJUe6t3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.guim.co.uk/img/media/59900576343e3eb9c228925499c3d03a76b3a7cd/16_0_973_584/master/973.jpg%3Fwidth%3D700%26quality%3D85%26auto%3Dformat%26fit%3Dmax%26s%3D66da60a6ab8773cb32b849774d9f0ff1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UoJUe6t3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.guim.co.uk/img/media/59900576343e3eb9c228925499c3d03a76b3a7cd/16_0_973_584/master/973.jpg%3Fwidth%3D700%26quality%3D85%26auto%3Dformat%26fit%3Dmax%26s%3D66da60a6ab8773cb32b849774d9f0ff1" alt="1" title="Source: guardian.com" width="700" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Yi6iLagH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.vox-cdn.com/thumbor/2DeadAHIDntdAXPA3PmhSS4truo%3D/0x0:628x308/1200x0/filters:focal%280x0:628x308%29:no_upscale%28%29/cdn.vox-cdn.com/uploads/chorus_asset/file/6238309/Screen_Shot_2016-03-24_at_10.46.22_AM.0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Yi6iLagH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.vox-cdn.com/thumbor/2DeadAHIDntdAXPA3PmhSS4truo%3D/0x0:628x308/1200x0/filters:focal%280x0:628x308%29:no_upscale%28%29/cdn.vox-cdn.com/uploads/chorus_asset/file/6238309/Screen_Shot_2016-03-24_at_10.46.22_AM.0.png" alt="2" title="Source: theverge.com" width="628" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Hicb-jY4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://digmedia.lucdh.nl/wp-content/uploads/2019/12/s3-tay_twitter_bot_microsoft-default-597.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Hicb-jY4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://digmedia.lucdh.nl/wp-content/uploads/2019/12/s3-tay_twitter_bot_microsoft-default-597.png" alt="3" title="Source: lucdh.nl" width="597" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By 4 am the next day Microsoft had shut down Tay – only 16 hours after it had launched.&lt;/p&gt;

&lt;p&gt;Microsoft may have had a great idea. Tay was meant to learn from its interactions, becoming more advanced with each interaction with a user. But they seemingly didn’t account for one crucial thing – &lt;strong&gt;the data itself may be bad&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But dirty data is not just hate speech, or outliers. It’s more than that. And understanding how to clean data is essential to ensure your data tells an accurate story&lt;/p&gt;

&lt;h2&gt;
  
  
  What is dirty data
&lt;/h2&gt;

&lt;p&gt;Microsoft’s chatbot fell prey to data bias, a problem most AI and predictive systems are affected by. If the dataset used to train an AI excludes certain groups, or has inherent societal biases, these systems may exacerbate societal biases.&lt;/p&gt;

&lt;p&gt;Think of the infamous &lt;a href="https://www.kaggle.com/c/titanic"&gt;Titanic dataset&lt;/a&gt;. Within a few minutes of Exploratory Data Analysis, you would realise that females were &lt;strong&gt;vastly&lt;/strong&gt; more likely to survive than men. If a travel insurance firm trained its system using the Titanic dataset, it would charge men markedly higher premiums than women. With that, a system meant to assess risk based on the destination of travel and number of people travelling, instead assesses risk based on gender.&lt;/p&gt;

&lt;p&gt;This may sound hypothetical, but &lt;a href="https://www.deseret.com/2012/4/3/20500723/racism-in-finance-major-banks-issue-higher-interest-rates-to-minorities"&gt;banks have been charging, on average, higher interest rates&lt;/a&gt; to people of colour. This may have been caused, in part, by AI systems that consider black borrowers riskier.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to (try) clean dirty data
&lt;/h2&gt;

&lt;p&gt;It’s true that data will never be clean – it will always have some level of bias and error, but by systematically evaluating the source, freshness, and attributes of the data being collected, bias and error can be reduced considerably.&lt;/p&gt;

&lt;p&gt;But how can this be done? To borrow from Kathy Baxter’s &lt;a href="https://medium.com/salesforce-ux/dirty-data-or-biased-data-6d55db6b5dc6"&gt;very good article&lt;/a&gt;: We can evaluate the correctness of data by asking 4 W’s – Where, When, Who, and What?&lt;/p&gt;

&lt;h3&gt;
  
  
  WHERE – Is your data source credible?
&lt;/h3&gt;

&lt;p&gt;The quality of your data is very important, and so it is crucial to consider where your data comes from. Could that source have a vested interest in having the data be a certain way? Might they have tweaked the data? It is very important that you get your data from a trusted, credible source.&lt;/p&gt;

&lt;p&gt;If you’re collecting the data yourself: &lt;strong&gt;have you followed the proper procedures for collecting data systematically?&lt;/strong&gt; Could the sample you collected the data from introduce bias into the data? These are all very key considerations to make your data credible.&lt;/p&gt;

&lt;p&gt;If you’re starting out in Data Science and are looking for credible, real-world datasets, public datasets from The &lt;a href="https://data.worldbank.org/"&gt;World Bank&lt;/a&gt;, &lt;a href="https://www.google.com/publicdata/directory"&gt;Google&lt;/a&gt;, and the &lt;a href="https://www.census.gov/data.html"&gt;US Census Bureau&lt;/a&gt; will do the job.&lt;/p&gt;

&lt;h3&gt;
  
  
  WHEN – Is your data source recent?
&lt;/h3&gt;

&lt;p&gt;You’ve probably heard that &lt;a href="https://medium.com/callforcode/the-amount-of-data-in-the-world-doubles-every-two-years-3c0be9263eb1"&gt;the total amount of data in the world doubles every two years&lt;/a&gt;. It’s an incredible statistic, but one of the problems with this is that there is way more data about the recent past than the more distant past.&lt;/p&gt;

&lt;p&gt;For example, a stock trading bot maker would have way more information about the movements in the stock market in the last month, than they would have of 5 years ago.&lt;/p&gt;

&lt;p&gt;This phenomenon is called &lt;strong&gt;&lt;a href="https://www.investopedia.com/recency-availability-bias-5206686"&gt;recency bias&lt;/a&gt;&lt;/strong&gt;, and while it can make your AI system good at finding short-term trends, it may falter on the more long-term, bigger-picture trends.&lt;/p&gt;

&lt;p&gt;However, the opposite is also true: a medical insurance firm making decisions based on data collected 5 years ago may not take into consideration the COVID-19 pandemic we’re still in the midst of.&lt;/p&gt;

&lt;p&gt;You will need to take into account the recency of your data, and decide if it is appropriate for your particular use case.&lt;/p&gt;

&lt;h3&gt;
  
  
  WHO – Is your data source representative?
&lt;/h3&gt;

&lt;p&gt;Your dataset needs to be representative of your target users/customers. For example, if an insurance firm was targeting European clients, it would not make sense to train their system with a dataset of American customers.&lt;/p&gt;

&lt;p&gt;But it’s not often that easy to know if your dataset is representative:&lt;/p&gt;

&lt;p&gt;People of colour have &lt;a href="https://www.webmd.com/a-to-z-guides/news/20220505/why-do-clinical-trials-still-underrepresent-minorities"&gt;historically been underrepresented in clinical trials&lt;/a&gt;. While the COVID-19 vaccine trials were markedly more diverse, this was still observable. This was not intentional – hospitals typically found in POC neighbourhoods tend to be underfunded and therefore unable to conduct trials. Pharmaceutical companies also accounted for age in these trials. Even though people over the age of 65 make up just 9% of the US population, they are vastly more likely to die of COVID-19. Pharmaceutical companies have therefore included a disproportionate amount of older people in vaccine trials.&lt;/p&gt;

&lt;h3&gt;
  
  
  WHAT – Could the data categories you are analysing have an inherent bias?
&lt;/h3&gt;

&lt;p&gt;Data categories are the different &lt;strong&gt;pieces of information&lt;/strong&gt; or &lt;strong&gt;variables&lt;/strong&gt; you are analysing - things like name, age, or location. Choosing what data categories to include is important because the presence of certain variables could introduce bias into your dataset.&lt;/p&gt;

&lt;p&gt;Due to certain laws, or organizational values, certain attributes are restricted:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Age&lt;/li&gt;
&lt;li&gt;  Race&lt;/li&gt;
&lt;li&gt;  Gender&lt;/li&gt;
&lt;li&gt;  National origin&lt;/li&gt;
&lt;li&gt;  Sexual orientation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These variables are prohibited in certain contexts like &lt;strong&gt;employing people&lt;/strong&gt; or providing &lt;strong&gt;government services&lt;/strong&gt;. Organisations tend to avoid them because they tend to introduce unwanted bias. It is generally advisable to stay away from these attributes unless your use case is specifically linked to them (e.g. for research purposes).&lt;/p&gt;




&lt;p&gt;It is true that data will never be clean, but that doesn’t mean it can’t still be useful.&lt;/p&gt;

&lt;p&gt;To quote Dean Abbott, “No data is clean, but most is useful.”&lt;/p&gt;

&lt;p&gt;So, go on and make your data useful! (after cleaning it)&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>beginners</category>
      <category>python</category>
      <category>programming</category>
    </item>
    <item>
      <title>The Normal and Binomial distributions, explained with Python</title>
      <dc:creator>darrendube</dc:creator>
      <pubDate>Mon, 16 May 2022 19:25:40 +0000</pubDate>
      <link>https://forem.com/darrendube/the-normal-and-binomial-distributions-explained-with-python-lm2</link>
      <guid>https://forem.com/darrendube/the-normal-and-binomial-distributions-explained-with-python-lm2</guid>
      <description>&lt;p&gt;&lt;em&gt;(Originally published on &lt;a href="https://darrendube.com/blog/data-science/normal-distribution-in-python/"&gt;darrendube.com&lt;/a&gt;).&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;The Binomial and Normal (or Gaussian) distributions are some of the most common distributions in Statistics. They are used anywhere from predicting movements in stock prices, to grading SAT tests. As an introduction to data visualisation in python, we will be plotting a binomial distribution, then plotting a normal estimation to the binomial.&lt;/p&gt;

&lt;p&gt;(If you've only come for the visualisation part, skip to this point)&lt;/p&gt;

&lt;h2&gt;
  
  
  What are the Normal and Binomial Distributions
&lt;/h2&gt;

&lt;p&gt;Even if you didn’t take a high school statistics class, you’ve probably still encountered the Gaussian (or normal) distribution in a math or science class.&lt;/p&gt;

&lt;p&gt;If you created a histogram to represent the heights of people in a class, it would likely create a bell curve, with the more common heights in the middle, and the less common ones on the sides.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1LqvrUnR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://d1hj4to4g9ba46.cloudfront.net/questions/460828.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1LqvrUnR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://d1hj4to4g9ba46.cloudfront.net/questions/460828.PNG" alt="Histogram of heights of people in a class" title="Source: toppr.com" width="572" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you increased the number of subjects in your sample, the graph would more and more closely resemble the shape of a normal distribution:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--twFindWx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/statisticsbyjim.com/wp-content/uploads/2018/04/probability_distribution_heights.png%3Fw%3D576%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--twFindWx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/statisticsbyjim.com/wp-content/uploads/2018/04/probability_distribution_heights.png%3Fw%3D576%26ssl%3D1" alt="Graph of 14 year olds' heights" title="Source: statisticsbyjim.com" width="576" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The probability distribution function of a normal distribution is :&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;f(x)=1σ2πe−12(x−μσ)!2 
f(x) = \frac{1}{\sigma\sqrt{2\pi}}
e^{ -\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^{!2}\,}
&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;f&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;σ&lt;/span&gt;&lt;span class="mord sqrt"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span class="svg-align"&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;2&lt;/span&gt;&lt;span class="mord mathnormal"&gt;π&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="hide-tail"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;e&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;−&lt;/span&gt;&lt;span class="mord mtight"&gt;&lt;span class="mopen nulldelimiter sizing reset-size3 size6"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line mtight"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter sizing reset-size3 size6"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="minner mtight"&gt;&lt;span class="minner mtight"&gt;&lt;span class="mopen sizing reset-size3 size6 mtight delimcenter"&gt;&lt;span class="mtight"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="mord mtight"&gt;&lt;span class="mopen nulldelimiter sizing reset-size3 size6"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;σ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line mtight"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;x&lt;/span&gt;&lt;span class="mbin mtight"&gt;−&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;μ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter sizing reset-size3 size6"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose sizing reset-size3 size6 mtight delimcenter"&gt;&lt;span class="mtight"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mclose mtight"&gt;!&lt;/span&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace mtight"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;The shape of the graph is determined by its &lt;a href="https://en.wikipedia.org/wiki/Mean"&gt;mean&lt;/a&gt; and &lt;a href="https://en.wikipedia.org/wiki/Standard_deviation"&gt;standard deviation&lt;/a&gt;. The graph is &lt;strong&gt;centred&lt;/strong&gt; around the mean, and the standard deviation determines how &lt;strong&gt;stretched&lt;/strong&gt; it is in the x-direction.&lt;/p&gt;

&lt;p&gt;Besides the heights of people in a class, many other random variables follow the normal distributions, including measurement error, SAT scores, and shoe sizes. The area under two points on the graph, divided by the area of the whole graph, gives the probability of a value between those two points.&lt;/p&gt;

&lt;p&gt;Closely related is the &lt;strong&gt;binomial distribution&lt;/strong&gt;. Even if you haven’t heard of it, it is very intuitive to understand.&lt;/p&gt;

&lt;p&gt;Consider a coin toss: the probability of hitting either heads or tails is 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;0.50.5&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;0.5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
. If there is a fixed number of trials, the binomial distribution is used to calculate the probability of, e.g., getting 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;22&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 heads in 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;1010&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;10&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 tries. It is represented by the probability density function:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;Px=(nCr)px(1−p)n−x
P_{x}=(nCr) p^{x} (1-p)^{n-x}
&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;span class="mord mathnormal"&gt;C&lt;/span&gt;&lt;span class="mord mathnormal"&gt;r&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="mclose"&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;span class="mbin mtight"&gt;−&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;meaning, in 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;nn&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 trials, each with a probability 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;pp&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 of success, the probability of getting 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;xx&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 successes is 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;PxP_{x}&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
. In the coin toss example, 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;n=10n=10&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;10&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;p=0.5p=0.5&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;0.5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, and success means getting heads. While it is possible that there will be no heads in all 10 trials, it is unlikely, hence 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;P0P_{0}&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 will be extremely low. Likewise, it is unlikely all 10 tosses will be heads, hence 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;P10P_{10}&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;10&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 will likely be low too. The more likely number of successes would be in the middle, with the most likely being 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;n×p(=10)n\times p (=10)&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;×&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;10&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
.&lt;/p&gt;

&lt;p&gt;If you increase the number of trials, the shape of the graph starts to look very familiar...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5UNTH-xC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.inchcalculator.com/wp-content/uploads/2021/11/binomial-distribution.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5UNTH-xC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.inchcalculator.com/wp-content/uploads/2021/11/binomial-distribution.png" alt="image of binomial distribution" title="Source: inchcalculator.com" width="880" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the number of attempts is large enough, the binomial distribution resembles a normal distribution. &lt;strong&gt;This means a normal distribution can be used to estimate the binomial by using 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;μ=np\mu=np&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;μ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 and 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;σ=np(1−p)\sigma=np(1-p)&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;σ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
.&lt;/strong&gt; This is very useful when, for instance, you're trying to find the probability it takes more than 30 tries when 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;n=100n=100&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;100&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 (which would normally require you to find 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;PxP_{x}&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 for &lt;strong&gt;every&lt;/strong&gt; number from 31-100).&lt;/p&gt;

&lt;p&gt;However, there's a catch: the binomial distribution deals with &lt;a href="https://www.g2.com/articles/discrete-vs-continuous-data"&gt;discrete&lt;/a&gt; variables (i.e. there is no 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;P8.443P_{8.443}&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;8.443&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 or 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;P3.142P_{3.142}&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;3.142&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, only whole numbers), whereas the normal distribution deals with continuous variables. This means the normal distribution is only an approximation to the binomial.&lt;/p&gt;

&lt;p&gt;I realise this is by no means an exhaustive introduction. If you're still &lt;em&gt;confused&lt;/em&gt;, &lt;a href="https://www.mathsisfun.com/data/standard-normal-distribution.html"&gt;this&lt;/a&gt; and &lt;a href="https://www.mathsisfun.com/data/standard-normal-distribution.html"&gt;this&lt;/a&gt; are more in-depth explanations.&lt;/p&gt;
&lt;h2&gt;
  
  
  Plotting the binomial distribution
&lt;/h2&gt;

&lt;p&gt;We can plot a graph of the probabilities associated with each number of tries. In this example, I’ll be using Python and &lt;a href="https://matplotlib.org/"&gt;matplotlib&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you do not have &lt;code&gt;matplotlib&lt;/code&gt; installed on Python yet, install it by typing &lt;code&gt;pip install matplotlib&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Begin by importing &lt;code&gt;matplotlib&lt;/code&gt; and &lt;code&gt;math&lt;/code&gt;. We'll need &lt;code&gt;math&lt;/code&gt; to get the value of 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;ee&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;e&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, and the 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;nCxnCx&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;span class="mord mathnormal"&gt;C&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;math&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pyplot&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Firstly, we need to define the probability density function of the binomial distribution. To recall:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;Px=(nCr)px(1−p)n−x
P_{x}=(nCr) p^{x} (1-p)^{n-x}
&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;span class="mord mathnormal"&gt;C&lt;/span&gt;&lt;span class="mord mathnormal"&gt;r&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="mclose"&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;span class="mbin mtight"&gt;−&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;



&lt;p&gt;In python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;binomial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;comb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, to make the binomial distribution more clearly resemble a normal distribution, I will make 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;nn&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 equal to 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;5050&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;50&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
. 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;pp&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 will be 0.5. We also need to initialise a list to store the 50 values we get from the binomial p.d.f for each value of 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;xx&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, and another list to store keys (that basically number each value of 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;xx&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 in the previous list).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;
&lt;span class="n"&gt;binomial_list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="n"&gt;keys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that we have initialised all the variables we need, we can now iterate over each number from 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;11&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 to 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;5050&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;50&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 to get values of 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;PxP_{x}&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 for each, and we need to fill the &lt;code&gt;keys[]&lt;/code&gt; list with numbers from 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;11&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 to 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;5050&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;50&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;binomial_list&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binomial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All that's left is to plot the graph!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pyplot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;binomial_list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;pyplot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;show&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And voila!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KgPNNxO6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/BThQyS1/Figure-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KgPNNxO6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/BThQyS1/Figure-1.png" alt="normal distribution" width="585" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, it clearly resembles a normal distribution. To see if it actually has the shape of a normal distribution, we can superimpose the normal curve by inserting this code (before the &lt;code&gt;pyplot.show()&lt;/code&gt; expression:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;normal_distribution&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sigma&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;sigma&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sigma&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pi&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;pyplot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;normal_distribution&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b936FiTA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/RDyzWsB/Figure-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b936FiTA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/RDyzWsB/Figure-1.png" alt="binomial and normal" width="583" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Originally published on &lt;a href="https://darrendube.com/blog/data-science/normal-distribution-in-python/"&gt;darrendube.com&lt;/a&gt;).&lt;/em&gt;&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>python</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Jamstack comments suck - but they don't have to</title>
      <dc:creator>darrendube</dc:creator>
      <pubDate>Mon, 24 May 2021 21:34:23 +0000</pubDate>
      <link>https://forem.com/darrendube/jamstack-comments-suck-but-they-don-t-have-to-5509</link>
      <guid>https://forem.com/darrendube/jamstack-comments-suck-but-they-don-t-have-to-5509</guid>
      <description>&lt;p&gt;Let's face it - Jamstack websites have many advantages, but adding comments easily isn't one of them.&lt;/p&gt;

&lt;p&gt;And for those of us with blogs, we know that a blog is never fully complete without comments. &lt;strong&gt;Blogging is meant to be a two way exchange, a way to build a community.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Jamstack's static nature means that comments don't come natively, but there is no shortage of third party comments providers - Disqus, Commentbox, Facebook Comments, among others. &lt;/p&gt;

&lt;p&gt;The problem is that most of them are either not free, or they have ads and privacy concerns.&lt;/p&gt;

&lt;p&gt;This is why I was excited when I discovered a comments app that's free, open source, and has no privacy issues.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Utterances
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://utteranc.es"&gt;Utterances&lt;/a&gt; is a free, open source application that essentially acts as a widget on your blog post, storing comments on &lt;a href="https://guides.github.com/features/issues/"&gt;Github Issues&lt;/a&gt;. It creates a GitHub Issue for every blog post on your blog, then stores the blog comments as comments on that issue. You can moderate comments by editing those issues. &lt;strong&gt;To see how it looks like on an actual page, head to &lt;a href="https://darrendube.com/blog/web-development/comments-in-jamstack-websites"&gt;my original post&lt;/a&gt; and scroll down to the end!&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Who is Utterances for
&lt;/h2&gt;

&lt;p&gt;Because Utterances runs on Github Issues, it requires commenters to have a GitHub account, and to sign in everytime they want to comment. Therefore, Utterances is more suited towards developer/tech blogs, where the majority of readers would have Github accounts already.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to set Utterances up
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;This tutorial is geared towards GatsbyJS websites, but will work for any react-based website.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;First, you have to install Utterances to the GitHub repo that your website is hosted on. The repo has to be public. Click &lt;a href="https://github.com/apps/utterances"&gt;here&lt;/a&gt; to install the app.&lt;/p&gt;

&lt;p&gt;Then, if you follow the instructions on &lt;a href="https://utteranc.es"&gt;Utterances' website&lt;/a&gt;, it gives you a simple script to insert into your HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;script&lt;/span&gt;
  &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://utteranc.es/client.js"&lt;/span&gt;
  &lt;span class="na"&gt;repo&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"[ENTER REPO HERE]"&lt;/span&gt;
  &lt;span class="na"&gt;issue&lt;/span&gt;&lt;span class="err"&gt;-&lt;/span&gt;&lt;span class="na"&gt;term&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"pathname"&lt;/span&gt;
  &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"github-light"&lt;/span&gt;
  &lt;span class="na"&gt;crossorigin&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"anonymous"&lt;/span&gt;
  &lt;span class="na"&gt;async&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;script&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, this solution &lt;strong&gt;only works for simple Static HTML websites&lt;/strong&gt;, and will &lt;strong&gt;not&lt;/strong&gt; work for react-based Jamstack websites like GatsbyJS and Next.js.&lt;/p&gt;

&lt;p&gt;Instead, make a Comments components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;//comments.js&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Comment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;commentBox&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"comments-section-wrapper"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"inner-section"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Comments&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;commentBox&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"comments"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Comment&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In your &lt;strong&gt;blog post template&lt;/strong&gt;, create a ref that is attached to the &lt;code&gt;commentBox&lt;/code&gt; prop on the &lt;code&gt;Comments&lt;/code&gt; component&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;//blogTemplate.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;commentBox&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createRef&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use the &lt;code&gt;useEffects&lt;/code&gt; hook to add the script tag to the &lt;code&gt;Comments&lt;/code&gt; Component using the ref:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;//blogTemplate.js&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
  &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;commentScript&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;script&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;commentScript&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;commentScript&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://utteranc.es/client.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;commentScript&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;repo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;darrendube/website&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// PLEASE CHANGE THIS TO YOUR REPO&lt;/span&gt;
    &lt;span class="nx"&gt;commentScript&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;issue-term&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;pathname&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;commentScript&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;utterances&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;commentScript&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;theme&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;preferred-color-scheme&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;commentScript&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;crossorigin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;anonymous&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;commentBox&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;commentBox&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;commentBox&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;commentScript&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Error adding utterances comments on: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;commentBox&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;commentBox&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now insert this &lt;code&gt;Comments&lt;/code&gt; component anywhere on your website:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;//blogTemplate.js&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Comments&lt;/span&gt; &lt;span class="nx"&gt;commentBox&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;commentBox&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Utterances provides a selection of 7 themes which you can find &lt;a href="https://utteranc.es"&gt;here&lt;/a&gt;. You can change the theme by changing the &lt;code&gt;theme&lt;/code&gt; value in the &lt;code&gt;useEffect&lt;/code&gt; hook. The widget is an iFrame so you can't use CSS to customise the comments - you are limited to the seven themes.&lt;/p&gt;

&lt;p&gt;And that's it! If you want to see this in action, head to &lt;a href="https://darrendube.com/blog/web-development/comments-in-jamstack-websites"&gt;my original post&lt;/a&gt; and leave a comment there!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>react</category>
    </item>
    <item>
      <title>Introduction to the Jamstack - the New Frontier in Web Development</title>
      <dc:creator>darrendube</dc:creator>
      <pubDate>Sat, 15 May 2021 17:33:49 +0000</pubDate>
      <link>https://forem.com/darrendube/introduction-to-the-jamstack-the-new-frontier-in-web-development-e07</link>
      <guid>https://forem.com/darrendube/introduction-to-the-jamstack-the-new-frontier-in-web-development-e07</guid>
      <description>&lt;p&gt;As a Web Developer, you've probably heard of the Jamstack. It's the buzzword in web development. But what exactly is it?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Jamstack is an abbreviation that stands for JavaScript, APIs, and Mark-up. It is an architecture that promises, among other things, faster, cheaper, and more secure sites. And, increasingly, more and more websites are switching over.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To be clear, JAMstack is not a specific technology, nor is it driven or controlled by any single entity. It's a community-led movement, an architecture with a collection of standards and best practices that gives faster and more secure websites. &lt;/p&gt;

&lt;p&gt;But to understand why it's so revolutionary, we have to understand what stacks are, what technologies traditional websites use, and why they are becoming more and more obsolete. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://darrendube.com/blog/web-development/jamstack#ddfl" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft6pah5cy2ff857d1g7j7.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Legacy websites
&lt;/h2&gt;

&lt;p&gt;There are many Web Development stacks out there: &lt;a href="https://www.liquidweb.com/kb/what-is-a-lamp-stack/" rel="noopener noreferrer"&gt;LAMPstack&lt;/a&gt;, &lt;a href="https://www.mongodb.com/mean-stack" rel="noopener noreferrer"&gt;MEANstack&lt;/a&gt;, &lt;a href="https://www.hostinger.com/tutorials/what-is-wamp" rel="noopener noreferrer"&gt;WAMPstack&lt;/a&gt;, among others. These refer to the technologies used such as Linux, MySQL, and PHP. While they have their different technologies and applications, they all pretty much work in the same way: legacy websites are programs that run on a server, and query data from a database, building each page every time a user loads a page. WordPress websites follow this architecture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2Fs5rRv51%2Flegacy-websites-diagram.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2Fs5rRv51%2Flegacy-websites-diagram.png" alt="Legacy-architecture-diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This approach has its advantages - they tend to be &lt;b&gt;easier&lt;/b&gt; for the average person to run, they can be &lt;b&gt;highly dynamic&lt;/b&gt; because the page is only built at load time, and they are &lt;b&gt;less reliant&lt;/b&gt; on third-party providers for dynamic functionality - since they run on a literal server!&lt;/p&gt;

&lt;p&gt;However, legacy websites tend to be slow (especially for those on unstable internet connections), harder and more expensive to scale, and less secure. So, in 2015, Mathias Biilmann, the CEO of Netlify, coined the term &lt;em&gt;JAMstack&lt;/em&gt;, which was later renamed &lt;em&gt;Jamstack&lt;/em&gt;, referring to a new Web architecture that he and Chris Bach, a co-founder, were working on at Netlify, and that other Web developers were starting to explore. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Jamstack
&lt;/h2&gt;

&lt;p&gt;Instead of a server processing a request, a pre-built HTML page is served from a Content Delivery Network (CDN) and delivered to the user. No server involved. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FYZT5vw2%2Fjamstack-websites-diagram.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FYZT5vw2%2Fjamstack-websites-diagram.png" alt="Jamstack-architecture-diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, just because no server is involved in the serving of webpages doesn't mean no servers are involved in the process at all. To understand why this is, we have to delve into the three component parts of Jamstack:&lt;/p&gt;

&lt;h3&gt;
  
  
  J is for &lt;strong&gt;JavaScript&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Introduced to the world in 1995 by Netscape, JavaScript has become synonymous with the web. It provides a way to code logic into websites, allowing them to respond to users actions (for example: checkboxes, form submissions, calls to action) - every time a websites does something more than just display static information, you have JavaScript to thank for it!&lt;/p&gt;

&lt;p&gt;Jamstack uses client-side JavaScript, with libraries like React and Vue, to design and make web apps that feel and act like mobile apps. &lt;/p&gt;

&lt;p&gt;You might already be familiar with popular JavaScript UI libraries like &lt;a href="https://reactjs.org" rel="noopener noreferrer"&gt;React&lt;/a&gt;, &lt;a href="https://vuejs.org" rel="noopener noreferrer"&gt;Vue&lt;/a&gt;, and &lt;a href="https://angular.io" rel="noopener noreferrer"&gt;Angular&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  A is for &lt;strong&gt;APIs&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Application Programming Interfaces (APIs)&lt;/strong&gt; are what allow two or more programs to talk to each other. They are how things like cryptocurrency trading bots can communicate with cryptocurrency exchanges without a human in the mix.&lt;/p&gt;

&lt;p&gt;Just because we've decoupled the website's frontend from its backend doesn't mean we can't make use of any server functionality. Third-party services can provide dynamic functionality like database access, payments, and authentication. Jamstack takes the &lt;b&gt;microservices&lt;/b&gt; approach, which is different from the monolithic approach (I go through this in more detail below).&lt;/p&gt;

&lt;p&gt;Headless CMSs are another example of APIs. Normal &lt;b&gt;&lt;a href="https://kinsta.com/knowledgebase/content-management-system/" rel="noopener noreferrer"&gt;Content Management Services&lt;/a&gt; (CMSs)&lt;/b&gt; (like WordPress) deal with both the website content and the frontend. Jamstack decouples this, meaning Headless CMSs deal only with the content, leaving the frontend to &lt;a href="http://darrendube.com/blog/web-development/static-site-generators-wordpress-alternative" rel="noopener noreferrer"&gt;Static Site Generators&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The decoupling of these services from the actual websites gives greater portability, increased speed, and a lower risk of attack.&lt;/p&gt;

&lt;h3&gt;
  
  
  M is for &lt;strong&gt;Mark-up&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The M part of Jamstack is probably its most important part. It stands for &lt;strong&gt;Mark-up&lt;/strong&gt;. This means that Static HTML files are served to the user. &lt;/p&gt;

&lt;p&gt;But this not only includes how the website is served to the user - almost all websites have JavaScript, APIs, and Mark-up in some form - M also includes how the pages are made in the first place. There are generally two approaches to generating Static HTML files:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Hand typing:&lt;/strong&gt; You can type out the HTML files yourself. This is more suited to small, simple websites.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Static Site Generators:&lt;/strong&gt; This is the most popular approach for Jamstack websites. An SSG generates Static HTML files from raw data (usually written in a lightweight mark-up language like Markdown) and templates. I go into this in more detail &lt;a href="http://darrendube.com/blog/web-development/static-site-generators-wordpress-alternative" rel="noopener noreferrer"&gt;in another article&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Because of the functionality and advantages that dynamic websites have over conventional static ones, static websites often get a bad rap for being too basic. While Jamstack sites are static in the sense that Static HTML files are served to the end user, &lt;strong&gt;APIs&lt;/strong&gt; and &lt;strong&gt;Mark-up&lt;/strong&gt; also make Jamstack websites comparably dynamic.&lt;/p&gt;

&lt;h2&gt;
  
  
  CDNs
&lt;/h2&gt;

&lt;p&gt;Unlike traditional web servers, which are usually in one place and serve dynamic, server-generated pages, &lt;strong&gt;Content Delivery Networks (CDNs)&lt;/strong&gt; are geographically distributed, storing website data on several servers around the world so requests can be serviced from the server geographically closest to the user. CDNs are still servers, but because they are distributed, you can't really pinpoint the exact physical server your website is hosted on.&lt;/p&gt;

&lt;p&gt;CDNs themselves can't generate web pages, but since Jamstack web pages are pre-built, they can be served from CDNs. &lt;/p&gt;

&lt;p&gt;Because CDNs host static sites, they don't have bandwidth and processing limitations, so this lowers the risk of your website going down. It also makes CDNs cheaper - in fact, most provide free hosting!&lt;/p&gt;

&lt;p&gt;Examples of serverless hosting providers are &lt;a href="https://netlify.com" rel="noopener noreferrer"&gt;Netlify&lt;/a&gt; and &lt;a href="https://vercel.com" rel="noopener noreferrer"&gt;Vercel&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Microservices vs. Monolithic Architecture
&lt;/h2&gt;

&lt;p&gt;Traditional websites are, simply put, built as a unit. They have all their functionality - comments, contact forms, authentication - built in. This functionality can still be in the form of plugins (like in the case of WordPress) but they are still a part of the overall website structure, and not external. This model is called a &lt;strong&gt;monolithic architecture&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The Jamstack takes the &lt;strong&gt;microservices&lt;/strong&gt; approach where parts of a website are broken up and outsourced to third parties through APIs. Examples can be using a payments provider like Square or Paypal to process payments, or using Auth0 for authentication.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FBGQD2W5%2Fmonolithic-vs-microservices.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FBGQD2W5%2Fmonolithic-vs-microservices.png" alt="microservices-vs-monolithic-diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A useful analogy created by &lt;a href="https://thenewstack.io/microservices-vs-monoliths-an-operational-comparison/" rel="noopener noreferrer"&gt;The New Stack&lt;/a&gt; is that of an air ticket booking website. The process of booking a ticket contains many sub-steps which, in this scenario, are &lt;em&gt;reserving the ticket&lt;/em&gt;, &lt;em&gt;billing the customer&lt;/em&gt;, and sending a &lt;em&gt;confirmation email&lt;/em&gt; that the ticket is booked. In a monolithic architecture, all three processes would be built into a single application. In a microservices architecture, however, each stage works independently of the other and can be outsourced to third parties. The core function of the website might be to book the ticket, but billing could be outsourced to a payments company like Stripe, and emailing could be outsourced to an email company like Mailchimp, all through APIs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Jamstack websites are usually called Static Sites because of how they are served to the user, but this sometimes gives the misconception that they can't have dynamic functionality when in fact they &lt;strong&gt;can&lt;/strong&gt; through the use of APIs and Headless CMSs.&lt;/p&gt;

&lt;p&gt;The Jamstack is a movement that's spreading across the web development world. Many established Web Developers &lt;a href="https://www.prnewswire.com/news-releases/modern-websites-are-built-on-the-jamstack-architecture-due-to-performance-reliability-and-speed-of-developer-workflows-according-to-industry-survey-by-netlify-301065730.html" rel="noopener noreferrer"&gt;are switching over&lt;/a&gt;. Maybe it's time you switched over too, don't you think?&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://darrendube.com/blog/web-development/static-site-generators-wordpress-alternative" rel="noopener noreferrer"&gt;Static Site Generators - A WordPress alternative&lt;/a&gt; &lt;br&gt;&lt;br&gt;
&lt;a href="https://jamstack.wtf" rel="noopener noreferrer"&gt;WTF is Jamstack?&lt;/a&gt; &lt;br&gt;&lt;br&gt;
&lt;a href="https://netlify.com/blog" rel="noopener noreferrer"&gt;Netlify's Blog&lt;/a&gt; &lt;br&gt;&lt;br&gt;
INFOGRAPHIC - The Jamstack, in a nutshell&lt;br&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>react</category>
    </item>
    <item>
      <title>Static Site Generators - the WordPress alternative no one's talking about</title>
      <dc:creator>darrendube</dc:creator>
      <pubDate>Sun, 28 Mar 2021 00:33:43 +0000</pubDate>
      <link>https://forem.com/darrendube/static-site-generators-the-wordpress-alternative-no-one-s-talking-about-11bj</link>
      <guid>https://forem.com/darrendube/static-site-generators-the-wordpress-alternative-no-one-s-talking-about-11bj</guid>
      <description>&lt;p&gt;We've all experienced it.&lt;/p&gt;

&lt;p&gt;Websites suddenly becoming slow for no reason, loading times in the double digits, or even the dreaded &lt;em&gt;"Error establishing a database connection"&lt;/em&gt;. It may come down to the hosting provider you are using, the size of your website, or even the complexity of your aesthetic design, but the crux of the matter is that:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WordPress is ageing.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Running on code first written in 2003, it was designed for a time in the evolution of the internet when waiting minutes for a website to load was not uncommon. We weren't as dependent on the internet then. But now? As a tech generation becomes more and more impatient, website loading times are becoming a crucial factor in the design process of a website, even being &lt;a href="https://www.searchenginejournal.com/google-the-web-is-faster-since-page-speed-became-a-ranking-factor/301847/" rel="noopener noreferrer"&gt;factored in by search engines when ranking&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So what's the solution to this problem? &lt;strong&gt;Static Site Generators!&lt;/strong&gt; (surprise, surprise).&lt;/p&gt;

&lt;p&gt;But to understand how SSGs work and how they solve WordPress' problems, we first need to understand how WordPress works, and why this is causing slow websites.&lt;/p&gt;

&lt;h2&gt;
  
  
  How WordPress Works
&lt;/h2&gt;

&lt;p&gt;A typical, barebones website consists of HTML (for the content and structure), CSS (for the design), and JS (for any logic or processing). For anyone starting out in Web Development, the normal inclination would be to write a separate HTML file for every page on your website. We would call this a &lt;strong&gt;static website&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Simple enough: you get easy customisation, no complex scripts to slow your site down, and a compact website that doesn't take up much space. Sure, this works for a simple website with 5 pages. But what about a blog with 50 posts? Or an e-commerce website with hundreds of products? I'm sure you can see where I'm going with this. With all these examples, sure, you can copy and paste a blog post template and edit the contents each time you want to write a new blog post, but that's taking away precious time. Time you could be spending writing blog posts.&lt;/p&gt;

&lt;p&gt;WordPress solves this problem by (and I'm massively oversimplifying here) storing page and blog post data in a database, separate from the styles. When a user visits a page on the website, WordPress executes PHP code, retrieving data from a database, and assembling this data into HTML and CSS. This is an example of what we call a &lt;strong&gt;dynamic website&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;All this code has to execute before the website has been rendered, while the user is waiting for the page to load, in a context where &lt;a href="https://www.entrepreneur.com/article/281986" rel="noopener noreferrer"&gt;40% of people will abandon a website that takes more than 3 seconds to load&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;An optimised WordPress website with the best hosting and minimal assets will take about 1-2 seconds to load. But a website with cheap, low-cost hosting (the type most of us bloggers/portfolio owners will probably use) will take about 4-5 seconds!&lt;/p&gt;

&lt;h2&gt;
  
  
  Static Site Generators
&lt;/h2&gt;

&lt;p&gt;Now, instead of retrieving data from a database and assembling HTML and CSS each time a website loads, imagine if we just prebuilt this HTML and CSS &lt;em&gt;before&lt;/em&gt; the user visited the website, and stored this instead. Instead of executing code, we deliver these files as-is when a person visits our site. This processing happens before the user visits the site, meaning the files are ready to be served as soon as a request is made.&lt;/p&gt;

&lt;p&gt;Think of an SSG as an application that inputs website data and outputs a folder with all the HTML, CSS, and assets.&lt;/p&gt;

&lt;p&gt;Therefore, while with WordPress we speak of load time, with Static Site Generators, this becomes almost negligible, and we shift our focus to &lt;a href="https://css-tricks.com/comparing-static-site-generator-build-times/" rel="noopener noreferrer"&gt;build time&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Static Site Generators are relatively new - below is the growth in popularity of the search term &lt;em&gt;"Static Site Generator"&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FQnKkvyt%2Fssg-search-trend.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FQnKkvyt%2Fssg-search-trend.png" alt="Google Trends for 'Static Site Generator'"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  PROS
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Performance
&lt;/h4&gt;

&lt;p&gt;Because Static Site Generators prebuild websites &lt;em&gt;before&lt;/em&gt; they are requested by users, load times are cut from several seconds to mere milliseconds!&lt;/p&gt;

&lt;p&gt;In-site navigation is also unbelievably fast. In fact, navigating from one page to another is almost instantaneous (Try it &lt;a href="https://darrendube.com/" rel="noopener noreferrer"&gt;now&lt;/a&gt;! This website is powered by an SSG). This is because the SSG I use (&lt;a href="https://gatsbyjs.com/" rel="noopener noreferrer"&gt;GatsbyJS&lt;/a&gt;) prefetches the files and assets of other pages on the website so that by the time you want to go to another page, it has everything ready!&lt;/p&gt;

&lt;h4&gt;
  
  
  Security
&lt;/h4&gt;

&lt;p&gt;Databases, servers, and outdated software running on them are a hacker's dream. &lt;a href="https://www.wpwhitesecurity.com/statistics-70-percent-wordpress-installations-vulnerable/" rel="noopener noreferrer"&gt;A study&lt;/a&gt; found that about 70% of WordPress websites had a security vulnerability!&lt;/p&gt;

&lt;p&gt;The reason is simple - the more servers involved and the more processes and executions done by a server, the more loopholes and vulnerabilities can be found.&lt;/p&gt;

&lt;p&gt;But by preloading our pages, we eliminate the need for any logic and work to be performed, thereby eliminating the risk of hackers injecting malicious code into these processes.&lt;/p&gt;

&lt;h4&gt;
  
  
  Cost
&lt;/h4&gt;

&lt;p&gt;To run a self-hosted WordPress website, you need to spend on average $5-10 a month on hosting plus about $10 annually for a domain. All in all, you could easily spend over $100 a year. With Static Site Generators, this goes down to $0 (or \$10 a year for a custom domain).&lt;/p&gt;

&lt;p&gt;Because no processing power is needed, you can host your website on free hosting providers like &lt;a href="https://netlify.com/" rel="noopener noreferrer"&gt;Netlify&lt;/a&gt; and &lt;a href="https://pages.github.com/" rel="noopener noreferrer"&gt;GitHub Pages&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Version Control
&lt;/h4&gt;

&lt;p&gt;Most Static Site Generator websites are published by pushing code to a remote git repository, where it is automatically built and deployed. Apart from making the deployment process easy, this makes it easy to revert to a previous version of your site should the need arise.&lt;/p&gt;

&lt;p&gt;But, as with anything, Static Site Generators also have some:&lt;/p&gt;

&lt;h3&gt;
  
  
  CONS
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Pretty steep learning curve
&lt;/h4&gt;

&lt;p&gt;(Unless you are already a programmer).&lt;/p&gt;

&lt;p&gt;One of the reasons WordPress is so popular is its relatively shallow learning curve. You get a GUI, a dashboard, and a text editor - literally everything short of a WYSIWYG editor.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.wpexplorer.com%2Fwp-content%2Fuploads%2Fwordpress-dashboard-guide-main-dashboard-widgets.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.wpexplorer.com%2Fwp-content%2Fuploads%2Fwordpress-dashboard-guide-main-dashboard-widgets.jpg" alt="A WordPress Dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Static Site Generators require writing content in Markdown - not very intuitive for the average person.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F5476205%2F32066320-35850040-ba34-11e7-8175-4d58f9735010.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F5476205%2F32066320-35850040-ba34-11e7-8175-4d58f9735010.png" alt="Writing in Markdown"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add to this their relatively small community compared to WordPress, and this makes the learning curve that much steeper.&lt;/p&gt;

&lt;h4&gt;
  
  
  No built-in commenting
&lt;/h4&gt;

&lt;p&gt;One of the many side-effects of not running on a server is that you don't get any services out of the box that require processing. That means comments, search, and most forms of contact forms will need third party services. A popular free third-party commenting service is &lt;a href="https://disqus.com/" rel="noopener noreferrer"&gt;Disqus&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Updating and Publishing the site requires tools on your computer
&lt;/h4&gt;

&lt;p&gt;This means that you can only update your website from a computer that has that particular Static Site Generator installed - plus other dependencies. A WordPress site, however, can be edited from any computer with a browser and an internet connection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Static Site Generators out there
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://gatsbyjs.com/" rel="noopener noreferrer"&gt;Gatsby&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Based on react and running on Javascript, GatsbyJS is very easy to transition to for existing web-developers who have already been working with Javascript. What makes it a popular choice is that it can be used to make &lt;a href="https://web.dev/progressive-web-apps/" rel="noopener noreferrer"&gt;Progressive Web Apps (PWAs)&lt;/a&gt;, and its websites are designed to be very fast for users. The &lt;a href="https://www.gatsbyjs.com/plugins/gatsby-plugin-image" rel="noopener noreferrer"&gt;gatsby-plugin-image&lt;/a&gt; plugin (and its predecessor, &lt;a href="https://www.gatsbyjs.com/plugins/gatsby-image/" rel="noopener noreferrer"&gt;gatsby-image&lt;/a&gt;) give GatsbyJS image-optimisation out of the box, with features such as resizing, blurring, and preoptimisation. GatsbyJS also has a very rich ecosystem with clear and comprehensive &lt;a href="https://www.gatsbyjs.com/docs/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;, and a fast growing community on GitHub. This all helps make GatsbyJS sites (like &lt;a href="https://darrendube.com/" rel="noopener noreferrer"&gt;this one&lt;/a&gt;) faster for users than websites made by other Static Site Generators.&lt;/p&gt;

&lt;p&gt;Examples of websites powered by GatsbyJS are: &lt;a href="https://airbnb.io/" rel="noopener noreferrer"&gt;Airbnb's Engineering and Data Science website&lt;/a&gt;, &lt;a href="https://figma.com/" rel="noopener noreferrer"&gt;Figma&lt;/a&gt;, &lt;a href="https://reactjs.org" rel="noopener noreferrer"&gt;ReactJS&lt;/a&gt;, &lt;a href="https://hopper.com" rel="noopener noreferrer"&gt;Hopper&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To &lt;strong&gt;get started&lt;/strong&gt; with GatsbyJS, head to &lt;a href="https://www.sitepoint.com/gatsby-guide/" rel="noopener noreferrer"&gt;Sitepoint's tutorial&lt;/a&gt;, &lt;a href="https://scottspence.com/2019/10/31/build-an-mdx-blog/" rel="noopener noreferrer"&gt;Scott Spence's tutorial&lt;/a&gt;, and GatsbyJS' official &lt;a href="https://www.gatsbyjs.com/docs/quick-start/" rel="noopener noreferrer"&gt;Quick Start&lt;/a&gt; page&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://gohugo.io/" rel="noopener noreferrer"&gt;Hugo&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hugo's strong point is that it is fast. Built with Go, Hugo websites often take milliseconds to build (compared to 30-60s for GatsbyJS). This is good for deployment and hosting services like Netlify, which allots 200 free build minutes a month and charges for minutes over this. Go, however, is not as ubiquitous in the Web Development space as Javascript, so this may be a turn off for some.&lt;/p&gt;

&lt;p&gt;Examples of websites powered by Hugo are: &lt;a href="https://getbootstrap.com/" rel="noopener noreferrer"&gt;Bootstrap&lt;/a&gt;, &lt;a href="https://kubernetes.com/" rel="noopener noreferrer"&gt;Kubernetes&lt;/a&gt;, &lt;a href="https://ghost.org" rel="noopener noreferrer"&gt;Ghost&lt;/a&gt;,and &lt;a href="https://coreui.io" rel="noopener noreferrer"&gt;CoreUI&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To &lt;strong&gt;get started&lt;/strong&gt; with Hugo, head to &lt;a href="https://thenewstack.io/tutorial-use-hugo-to-generate-a-static-website/" rel="noopener noreferrer"&gt;The New Stack's Hugo tutorial&lt;/a&gt;, and Hugo's &lt;a href="https://gohugo.io/getting-started/quick-start/" rel="noopener noreferrer"&gt;quick start&lt;/a&gt; page.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://jekyllrb.com/" rel="noopener noreferrer"&gt;Jekyll&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Being one of the earlier ones (made in 2008), Jekyll popularised the concept of a Static Site Generator. Running on Ruby, its shallow learning curve and its relative maturity make it a popular choice for many web developers. While other Static Site Generators have come on the scene, Jekyll remains widely used in the Web Development space.&lt;/p&gt;

&lt;p&gt;Examples of websites powered by Jekyll are: &lt;a href="https://rubyonrails.org/" rel="noopener noreferrer"&gt;Ruby on Rails&lt;/a&gt;, and &lt;a href="https://frame.ai/" rel="noopener noreferrer"&gt;Frame AI&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To &lt;strong&gt;get started&lt;/strong&gt; with Jekyll, head to &lt;a href="https://opensource.com/article/17/4/getting-started-jekyll" rel="noopener noreferrer"&gt;Open Source's Jekyll tutorials&lt;/a&gt;, &lt;a href="https://www.taniarascia.com/make-a-static-website-with-jekyll/" rel="noopener noreferrer"&gt;Tania Rascia's tutorial&lt;/a&gt;, and &lt;a href="https://jekyllrb.com/tutorials/home/" rel="noopener noreferrer"&gt;Jekyll's official tutorials&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://11ty.dev/" rel="noopener noreferrer"&gt;Eleventy&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Billing itself as a &lt;em&gt;simpler&lt;/em&gt; Static Site Generator, Eleventy is a Static Site Generator for those that just want the job done. Eleventy improved on the main problems with other Static Site Generators like Hugo and Jekyll. Jekyll has been around for some time, but it is viewed as too slow for some. Hugo is fast, but it requires using Go, a programming language that is unfamiliar for most Web Developers. Eleventy is fast, and uses Javascript, a language that most Web Developers already know.&lt;/p&gt;

&lt;p&gt;An example of a website powered by eleventy is &lt;a href="https://11ty.dev" rel="noopener noreferrer"&gt;their website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To &lt;strong&gt;get started&lt;/strong&gt; with Eleventy, head to &lt;a href="https://www.sitepoint.com/getting-started-with-eleventy/" rel="noopener noreferrer"&gt;Craig Buckler's tutorial&lt;/a&gt;, &lt;a href="https://tatianamac.com/posts/beginner-eleventy-tutorial-parti/" rel="noopener noreferrer"&gt;Tatiana Mac's tutorial&lt;/a&gt;, and Eleventy's official &lt;a href="https://www.11ty.dev/docs/getting-started/" rel="noopener noreferrer"&gt;getting started&lt;/a&gt; page.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;You can find a more exhaustive list of Static Site Generators at &lt;a href="https://staticgen.com" rel="noopener noreferrer"&gt;staticgen.com&lt;/a&gt;. If you are interested in adapting your website to Static Site Generators or making a new one altogether, visit &lt;a href="https://www.netlify.com/jamstack/" rel="noopener noreferrer"&gt;this page&lt;/a&gt; which talks about &lt;strong&gt;JAMstack&lt;/strong&gt;, the greater movement behind Static Site Generators, and a new approach to web development that creates faster and more secure websites.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Subscribe at &lt;a href="https://darrendube.com" rel="noopener noreferrer"&gt;darrendube.com&lt;/a&gt; for more posts like this&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Importance of Having a Personal Website</title>
      <dc:creator>darrendube</dc:creator>
      <pubDate>Tue, 02 Mar 2021 10:10:57 +0000</pubDate>
      <link>https://forem.com/darrendube/the-importance-of-having-a-personal-website-2i37</link>
      <guid>https://forem.com/darrendube/the-importance-of-having-a-personal-website-2i37</guid>
      <description>&lt;p&gt;Not long ago, the internet was a luxury, reserved for the select few. Today, anyone can establish an online presence with under US$10. And nowadays, with tools like WordPress and Wix, you don’t even have to know how to code. But do you really need your own website?&lt;/p&gt;

&lt;p&gt;Here are four reasons to have a personal website:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. You get to control your personal brand
&lt;/h3&gt;

&lt;p&gt;77% of employers say they google candidate’s names as part of the hiring process. For most of us, they won’t find anything meaningful – probably a few tweets, or articles you’ve written. By having a personal website, you get to control your narrative, and what others see when they search you. You get to show recruiters the REAL you, and I think that’s a very powerful thing to be able to do.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. It’s a useful way to show your creativity
&lt;/h3&gt;

&lt;p&gt;The thing with a CV/resume is that, while you can add some design to it, you are somewhat limited in the amount of creativity you can show. They have to be straight to the point. Websites give you the opportunity to show your creative side, and this could give you a competitive advantage. If you are in the art or design industry, your personal website would be the place to show off your portfolio.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Not to mention the money you could earn
&lt;/h3&gt;

&lt;p&gt;This is probably the main reason people set up personal websites. Blogs are increasingly becoming a source of income. An example is Neil Patel (neilpatel.com), who earns more than US$300000 a month from one of his blogs. You may not earn that much, but imagine if you earned $2000 a month, just from writing a few blog posts a week! Other ways to monetize your website are affiliate marketing, sponsorships, and ads, the intricacies of which are beyond the scope of this post.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Contact
&lt;/h3&gt;

&lt;p&gt;You’ve probably experienced this – you suddenly think of an old friend you last spoke to years ago, so you google them, but you can’t seem to find their contact details. If only they had a personal website with all their contact details!&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Stand out
&lt;/h3&gt;

&lt;p&gt;Self-explanatory: most people don’t have a personal website.&lt;/p&gt;

&lt;p&gt;So what should you put on your website? You could start a blog about yourself or anything you have expertise in. If you are in the creativity field, it could be where you keep your portfolio of work you have done. If you want, your personal website could also double as an extension of your CV. You could describe your work experience in more detail, with images and infographics. For some inspiration, see some personal websites below:&lt;/p&gt;

&lt;p&gt;Sean Halpin – &lt;a href="https://seanhalpin.design"&gt;https://seanhalpin.design&lt;/a&gt;&lt;br&gt;
Joshua McCartney – &lt;a href="https://joshuamccartney.com"&gt;https://joshuamccartney.com&lt;/a&gt; &lt;br&gt;
Roxine Kee – &lt;a href="https://roxinekee.com"&gt;https://roxinekee.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, how do you go about making your website? &lt;/p&gt;

&lt;p&gt;Head to &lt;a href="https://darrendube.com"&gt;darrendube.com&lt;/a&gt; to read my other posts 😊.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>discuss</category>
      <category>codenewbie</category>
      <category>javascript</category>
    </item>
    <item>
      <title>We should be teaching our kids how to code. Or should we?</title>
      <dc:creator>darrendube</dc:creator>
      <pubDate>Tue, 16 Feb 2021 13:21:09 +0000</pubDate>
      <link>https://forem.com/darrendube/we-should-be-teaching-our-kids-how-to-code-or-should-we-3ml4</link>
      <guid>https://forem.com/darrendube/we-should-be-teaching-our-kids-how-to-code-or-should-we-3ml4</guid>
      <description>&lt;p&gt;The debate over whether children should be taught to code in school has been going on for quite a while now. One side says that coding is the new literacy, and everyone should know how to. The other side rejects this claim.&lt;/p&gt;

&lt;p&gt;First of all, though the idea that coding will be beneficial to children is still under debate, I do not envisage it ever being at the same level as indispensable skills like reading or writing. Coding is not a skill needed by everyone. An actuary may benefit from knowing how to code, but a nurse wouldn't. Coding is beneficial only if it solves a problem. People should not learn how to code just because. Jeff Atwood said about this argument in &lt;a href="https://blog.codinghorror.com/please-dont-learn-to-code/"&gt;an article of his&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It assumes that coding is the goal. Software developers tend to be software addicts who think their job is to write code. But it's not. Their job is to solve problems.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Some people say coding could make our kids get better at problem-solving. But so could chess. And maths. And sports. My point is that there are many other skills that would be beneficial to kids. Coding is a practical subject, and if schools started teaching it, they might probably take away all the practicalness from it and teach it just like every other subject.&lt;/p&gt;

&lt;p&gt;We could instead introduce kids to code and get them to know how it looks like. Then it would be their choice to continue, either in a club or in their own time on platforms such as Codecademy and SoloLearn. Coding should not be forced on children in any way, as by doing so, we risk sucking the creativity out of it, the very skill we are trying to grow.&lt;/p&gt;

&lt;p&gt;What do you think about teaching kids to code? Leave a comment below!&lt;/p&gt;

</description>
      <category>healthydebate</category>
      <category>discuss</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
