<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Posts on Bloging</title>
		<link>https://blog.programiraj.ba/posts/</link>
		<description>Recent content in Posts on Bloging</description>
		<generator>Hugo -- gohugo.io</generator>
		<language>en-us</language>
		<copyright>This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.</copyright>
		<lastBuildDate>Wed, 16 Jan 2019 12:38:26 +0100</lastBuildDate>
		<atom:link href="https://blog.programiraj.ba/posts/index.xml" rel="self" type="application/rss+xml" />
		
		<item>
			<title>Some Presentations of Data</title>
			<link>https://blog.programiraj.ba/posts/some-presentations-of-data/</link>
			<pubDate>Wed, 16 Jan 2019 12:38:26 +0100</pubDate>
			
			<guid>https://blog.programiraj.ba/posts/some-presentations-of-data/</guid>
			<description>The collection, organisation and analysis of numerical information are all subject called statistics. Pieces of numerical and other information are called data. Data is &amp;lsquo;a series of facts from which conclusions may be drawn&amp;rsquo;.
In order to collect data you need to observe or to measure some property. This property is called variable.
Tables Let&amp;rsquo;s look at this data set:
13, 11, 10, 14, 14, 11, 9, 7, 22, 20, 24</description>
			<content type="html"><![CDATA[

<p>The collection, organisation and analysis of numerical information are all subject called <strong>statistics</strong>. Pieces of numerical and other information are called <strong>data</strong>. <strong>Data</strong> is &lsquo;a series of facts from which conclusions may be drawn&rsquo;.</p>

<p>In order to collect data you need to observe or to measure some property. This property is called variable.</p>

<h2 id="tables">Tables</h2>

<p>Let&rsquo;s look at this data set:</p>

<p>13, 11, 10, 14, 14, 11, 9, 7, 22, 20, 24</p>

<p>What conslusion can we draw? It doesn&rsquo;t mean anything to us.</p>

<p>But if we see table below we can get some clue that this is data about soccer games of German clubs in 2017 and data is in column AS. We still don&rsquo;t know what data means because we don&rsquo;t know what column AS means.</p>

<table>
<thead>
<tr>
<th>Div</th>
<th>Date</th>
<th>HomeTeam</th>
<th>AwayTeam</th>
<th>FTHG</th>
<th>FTAG</th>
<th>FTR</th>
<th>HTHG</th>
<th>HTR</th>
<th>HS</th>
<th>AS</th>
<th>B365H</th>
</tr>
</thead>

<tbody>
<tr>
<td>D1</td>
<td>18/08/17</td>
<td>Bayern Munich</td>
<td>Leverkusen</td>
<td>3</td>
<td>1</td>
<td>H</td>
<td>2</td>
<td>0</td>
<td>H</td>
<td>13</td>
<td>19</td>
</tr>

<tr>
<td>D1</td>
<td>19/08/17</td>
<td>Hamburg</td>
<td>Augsburg</td>
<td>1</td>
<td>0</td>
<td>H</td>
<td>1</td>
<td>0</td>
<td>H</td>
<td>11</td>
<td>2.1</td>
</tr>

<tr>
<td>D1</td>
<td>19/08/17</td>
<td>Hertha</td>
<td>Stuttgart</td>
<td>2</td>
<td>0</td>
<td>H</td>
<td>0</td>
<td>0</td>
<td>D</td>
<td>10</td>
<td>2</td>
</tr>

<tr>
<td>D1</td>
<td>19/08/17</td>
<td>Hoffenheim</td>
<td>Werder Bremen</td>
<td>1</td>
<td>0</td>
<td>H</td>
<td>0</td>
<td>0</td>
<td>D</td>
<td>14</td>
<td>1.75</td>
</tr>

<tr>
<td>D1</td>
<td>19/08/17</td>
<td>Mainz</td>
<td>Hannover</td>
<td>0</td>
<td>1</td>
<td>A</td>
<td>0</td>
<td>0</td>
<td>D</td>
<td>14</td>
<td>2</td>
</tr>

<tr>
<td>D1</td>
<td>19/08/17</td>
<td>Schalke 04</td>
<td>RB Leipzig</td>
<td>2</td>
<td>0</td>
<td>H</td>
<td>1</td>
<td>0</td>
<td>H</td>
<td>11</td>
<td>2.8</td>
</tr>

<tr>
<td>D1</td>
<td>19/08/17</td>
<td>Wolfsburg</td>
<td>Dortmund</td>
<td>0</td>
<td>3</td>
<td>A</td>
<td>0</td>
<td>2</td>
<td>A</td>
<td>9</td>
<td>3.8</td>
</tr>

<tr>
<td>D1</td>
<td>20/08/17</td>
<td>Freiburg</td>
<td>Ein Frankfurt</td>
<td>0</td>
<td>0</td>
<td>D</td>
<td>0</td>
<td>0</td>
<td>D</td>
<td>7</td>
<td>2.45</td>
</tr>

<tr>
<td>D1</td>
<td>20/08/17</td>
<td>M&rsquo;gladbach</td>
<td>FC Koln</td>
<td>1</td>
<td>0</td>
<td>H</td>
<td>0</td>
<td>0</td>
<td>D</td>
<td>22</td>
<td>1.91</td>
</tr>

<tr>
<td>D1</td>
<td>25/08/17</td>
<td>FC Koln</td>
<td>Hamburg</td>
<td>1</td>
<td>3</td>
<td>A</td>
<td>0</td>
<td>2</td>
<td>A</td>
<td>20</td>
<td>1.95</td>
</tr>

<tr>
<td>D1</td>
<td>26/08/17</td>
<td>Augsburg</td>
<td>M&rsquo;gladbach</td>
<td>2</td>
<td>2</td>
<td>D</td>
<td>1</td>
<td>2</td>
<td>A</td>
<td>24</td>
<td>3.25</td>
</tr>
</tbody>
</table>

<p>But I also have this information:</p>

<ul>
<li>Div = League Division</li>
<li>Date = Match Date (dd/mm/yy)</li>
<li>HomeTeam = Home Tea</li>
<li>AwayTeam = Away Team</li>
<li>FTHG and HG = Full Time Home Team Goals</li>
<li>FTAG and AG = Full Time Away Team Goals</li>
<li>FTR and Res = Full Time Result (H=Home Win, D=Draw, A=Away Win)</li>
<li>HTHG = Half Time Home Team Goals</li>
<li>HTR = Half Time Result (H=Home Win, D=Draw, A=Away Win)</li>
<li>HS = Home Team Shots</li>
<li><strong>AS = Away Team Shots</strong></li>
<li>B365H = Bet365 home win odds</li>
</ul>

<p>So now we know that 13, 11, 10, 14, 14, 11, 9, 7, 22, 20, 24 are Shots that Away team made in game. So 13 is shots (to goal) of Leverkusen in game against Bayern Munich on 18/08/17, 11 is number of shots that Ausburg make in game against HAmburg on 19/08/17.</p>

<h1 id="types-of-data-variables">Types of data - variables</h1>

<p>A variable is <strong>qualitative</strong> if it not possible to take a numerical value(Leauge Division, Date,Team name, Full Time Result)
A variable is <strong>quantitative</strong> if it can take numerical value (Full Time Home Team Goals,Away Team Shots). Quantitative variable can be <strong>continuous</strong> or <strong>discrete</strong>. Continuous variable can take any value in given range (Bet365 home win odds). Discrete variable has clear steps between possible values Full Time Away Team Goals can&rsquo;t take value 1.25.</p>

<p>As You can see presenting data in table provides a lot of information. Data in table tells a lot of, but this data is fine-grained. What if we want to know total or average team shots in season this is not right type of presentation.</p>

<h1 id="mean-median-mode-and-range">Mean Median Mode and Range</h1>

<p>Let us make some digression and explain what is Mean, Median and Mode.</p>

<p>Data set: 4, 5, 3, 8, 2, 2, 10, 9</p>

<p><strong>Mean(or average)</strong> is number that you get when add all data points and divide by the number of data points. (4 + 5 + 3 + 8 + 2 + 2 + 10 +9)/8 = <sup>43</sup>&frasl;<sub>8</sub> = 5.375</p>

<p>mean=sum of data# of data points</p>

<p><strong>Median</strong> is the middle number, found by ordering all data points and picking out the one in the middle (or if there are two middle numbers, taking the mean of those two numbers).
4 and 5 (two middle numbers)
<sup>9</sup>&frasl;<sub>2</sub> = 4.5.
For example if number of variables in data set is even  4, 5, 7, 12, 22 then mean is number in middle of ordered data set 7.</p>

<p><strong>Mode</strong> is the most frequent number, the number that occurs the highest number of times, in case of our example data set 2. There can be no mode (1,2,3,4) Mode = {}, one mode(1,1,2,3,4) Mode = {1}, or multiple modes(1,1,2,2,3,4,5) Mode = {1, 2} in a dataset.</p>

<p><strong>Range</strong> The largest value in the list is 10, and the smallest is 2, so the range is 10 - 2 = 8 (max - min).</p>

<h2 id="steam-and-leaf">Steam-and-leaf</h2>

<p>One interesting presentation is steam-and-leaf</p>

<p>Suppose that a height of children in one class of elementary school is measured and data set is:</p>

<p>65, 54, 76, 72, 71, 83, 72, 92, 60, 42, 73, 84, 72, 97, 72, 91, 53, 63, 84, 85</p>

<p>Let us sort data and take the leading digit (10&rsquo;s digit) as stem, and trailing digits are leafs.</p>

<p>42, 53, 54, 60, 63, 65, 71, 72, 72, 72, 72, 73, 76, 83, 84, 84, 85, 91, 92, 97</p>

<table>
<thead>
<tr>
<th>Steam</th>
<th>Leaf</th>
</tr>
</thead>

<tbody>
<tr>
<td>4</td>
<td>2</td>
</tr>

<tr>
<td>5</td>
<td>34</td>
</tr>

<tr>
<td>6</td>
<td>035</td>
</tr>

<tr>
<td>7</td>
<td>1222236</td>
</tr>

<tr>
<td>8</td>
<td>3445</td>
</tr>

<tr>
<td>9</td>
<td>127</td>
</tr>
</tbody>
</table>

<p>4|2 means</p>

<p>5|34 means 53 and 54</p>

<p>If You turn this on side you can see the &ldquo;shape&rdquo; of the height distribution and all data is visible (maintained).</p>

<p>This is called ordered steam-and-leaf because leaf are ordered |7|<strong>1222236</strong>.</p>

<p>Depending of data set stem can be taken as two digits.
164 184 186 175 187</p>

<p>16|4</p>

<p>17|5</p>

<p>18|467</p>

<p>If data set is large stem-and-leaf diagram is not best method of displaying data and you need to use other methods.</p>

<h2 id="tally">Tally</h2>

<p>For large data sets of data you may wish to divide the data into groups, called <strong>classes</strong>.</p>

<figure>
    <img src="/img/posts/some-presentations-of-data/jail.jpg"/> <figcaption>
            <h4>Modern tally</h4>
        </figcaption>
</figure>


<p>We can use tally to present data. For example favorite drinks of 62 students can be presented like this.</p>

<figure>
    <img src="/img/posts/some-presentations-of-data/drinks_tally.gif"/> 
</figure>


<h2 id="histogram">Histogram</h2>

<p>Data is collected from big food shoop from all types of cerelars and amout of sodium is in cerelars is variable.
Data is presented in next table as grouped frequency distribution. [0-49], [50-99] &hellip; are classes</p>

<table>
<thead>
<tr>
<th>Amount of sodium (mg)</th>
<th>Tally</th>
<th>Frequency</th>
</tr>
</thead>

<tbody>
<tr>
<td>0-49</td>
<td>***** ***** **</td>
<td>12</td>
</tr>

<tr>
<td>50-99</td>
<td>*****</td>
<td>5</td>
</tr>

<tr>
<td>100-149</td>
<td>***** ***** **</td>
<td>12</td>
</tr>

<tr>
<td>150-199</td>
<td>***** ***** ***** **</td>
<td>17</td>
</tr>

<tr>
<td>200-249</td>
<td>***** ***** ***** ***** *</td>
<td>21</td>
</tr>

<tr>
<td>250-299</td>
<td>***** ****</td>
<td>9</td>
</tr>

<tr>
<td>300-349</td>
<td>*</td>
<td>1</td>
</tr>
</tbody>
</table>

<p>There is no clear rule about how many classes should be chosen or what size they should be, but it is usual to have 5-10 classes.</p>

<p>Grouping data into classes means losing some information. We can see in table that there are 5 types of cereals with amount of sodium between 50 and 99 but we don&rsquo;t know exact values of observations.</p>

<p>Amount of sodium is <strong>continuous variable</strong> and amount is rounded to the nearest mg. Class labeled 50-99 would contain values from 49.5 up to (but not including) 99.5. These real endpoints 49.5 and 99.5 are referred as <strong>class boundaries</strong>. 49.5 &lt;= Class 50-99 &lt; 99.5 or [49.5-99.5)</p>

<p>When a grouped frequency distribution contains continuous data, one form of display is the <strong>histogram</strong>.</p>

<p>Histogram looks similar to a bar chart.</p>

<p>A chart which represents continuous data is a <strong>histogram</strong> if
 - the bars have no space between them (they mey be bars of height zero)
 - the area of each bar is proportional to the frequency</p>

<figure>
    <img src="/img/posts/some-presentations-of-data/histogram-apples.jpg"/> 
</figure>


<p>widht-of-class * height = frequency</p>

<p>height = frequency / widht-of-class</p>

<p>Height is known as <strong>frequency density</strong></p>

<p>Time is up, for this post :)</p>

<figure>
    <img src="/img/posts/some-presentations-of-data/clock.jpg"/> 
</figure>

]]></content>
		</item>
		
		<item>
			<title>Continuous Deployment</title>
			<link>https://blog.programiraj.ba/posts/continuous-deployment/</link>
			<pubDate>Fri, 28 Dec 2018 03:01:06 +0100</pubDate>
			
			<guid>https://blog.programiraj.ba/posts/continuous-deployment/</guid>
			<description>When I created first post I hat to generated site (using hugo) and I had to use ftp to upload files to programiraj.ba site.
Do I want to do this every time I make or change content ? No one sane would like to do that. And rule of thumb is when You have to do something more than three times automate it.
What I want is that every time i push changes to master to build site with hugo and deploy it to programiraj.</description>
			<content type="html"><![CDATA[<p>When I created first post I hat to generated site (using hugo) and I had to use ftp to upload files to programiraj.ba site.</p>

<p>Do I want to do this every time I make or change content ?
No one sane would like to do that.
And rule of thumb is when You have to do something more than three times automate it.</p>

<p>What I want is that every time i push changes to master to build site with hugo and deploy it to programiraj.ba</p>

<p>This is called <strong>continuous deployment (CD).</strong>
If this repository was on bitbucket this could be done using <a href="https://bitbucket.org/product/features/pipelines" target="_blank">bitbucket pipelines</a> or if I had <a href="https://jenkins.io/" target="_blank">Jenkins</a> instance installed on AWS. Let us now use <a href="https://circleci.com/" target="_blank">CircleCI</a> (and leave bitbucket pipelines for some other tasks in future).</p>

<p>Every CI/CD tool has some kind of pipeline which is usually described with some yaml, json file or by some scripting language that describes process of integration and deployment. Those include some jobs, commands, executors, steps, workflows etc&hellip;</p>

<p>Bottom line is that You have to know how to tell CI/CD system what You want to do.</p>

<p>Let&rsquo;s to describe process in pseudo pipeline steps:</p>

<ol>
<li><p>When I push new content to github on master branch checkout new code</p></li>

<li><p>Build site with hugo</p></li>

<li><p>Publish new site on programiraj.ba (upload via ftp)</p></li>
</ol>

<p>For step 1. we have to options pooling or notification (usually via web hooks). Pooling is process where CircleCi (or other CI/CD tool like Jenkins) checks are there any changes on github for every x minutes (or any time period You set), second option is when there is push on master github notifies CircleCi.</p>

<p>Step 2. and 3. are all done on CircleCI.</p>

<p>We could also add more steps to notify by email one or more persons that there is change on site but let&rsquo;s focus now only on this 3 steps.</p>

<p>CirceCI works like this:</p>

<ol>
<li><p>Create a directory called .circleci in the root directory of your local GitHub or Bitbucket code repository.</p></li>

<li><p>Add a config.yml file in the .circleci directory.</p></li>
</ol>

<p>We must learn how to write config.yml to do steps 2. and 3.</p>

<p>For this site I use this script</p>

<pre><code>version: 2.1
jobs:
  build-publish-site:
    docker:
    - image: abazovic/hugo:1.0.0
    steps:
    - checkout
    - run:
          name: &quot;Pull Submodules&quot;
          command: |
            git submodule init
            git submodule update --remote
    - run:
        name: &quot;Run Hugo for blog&quot;
        command: cd blog &amp;&amp; HUGO_ENV=production hugo -v
    - run:
        name: &quot;Run Hugo for homepage&quot;
        command: cd home &amp;&amp; HUGO_ENV=production hugo -v
    - run:
        name: &quot;Deploy website&quot;
        command: deploy/deploy.sh
workflows:
  version: 2
  workflow:
    jobs:
    - build-publish-site
</code></pre>

<p>You can find this script on <a href="https://github.com/MirzaAbazovic/programiraj.ba" target="_blank">https://github.com/MirzaAbazovic/programiraj.ba</a> and also all code that I use to deploy <a href="https://programiraj.ba" target="_blank">https://programiraj.ba</a> and <a href="https://blog.programiraj.ba" target="_blank">https://blog.programiraj.ba</a></p>

<p>In plain English this script has one <code>workflow</code> that has one job <code>build-publish-site</code>. Job is running on docker image <code>abazovic/hugo:1.0.0</code> and  has steps to:
1. checkout code <code>checkout</code></p>

<ol>
<li><p><strong>Pull Submodules</strong> Because I use two themes that I added as git submodules.</p></li>

<li><p><strong>Run Hugo for blog</strong> build static site for blog.</p></li>

<li><p><strong>&ldquo;Run Hugo for homepage</strong> build static site for home page.</p></li>

<li><p><strong>Deploy website</strong> Deploy it (upload files via lftp) using script <a href="https://github.com/MirzaAbazovic/programiraj.ba/blob/master/deploy/deploy.sh" target="_blank">deploy.sh</a></p></li>
</ol>

<p>What was tricky:</p>

<ol>
<li><p>Make custom docker image with installed software: hugo and lftp (will describe this in some other post)</p></li>

<li><p>Had some problems with git submodules, after <code>checkout</code> step I had to explicitly call
git submodule init and git submodule update &ndash;remote</p></li>

<li><p>I also had to write script to upload folder with sub folders generated by hugo to remote folder by ftp protocol. Script uses <a href="https://lftp.yar.ru/" target="_blank">lftp</a></p></li>
</ol>

<p>Script for upload</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="cp">#!/bin/bash
</span><span class="cp"></span><span class="nb">echo</span> <span class="s2">&#34;Upload all files from blog/public to blog.programiraj.ba using lftp&#34;</span>
lftp -e <span class="s2">&#34;set ftp:ssl-allow no; mirror -R -P 5  ~/project/blog/public /blog.programiraj.ba; quit&#34;</span> -u <span class="nv">$FTP_USERNAME</span>,<span class="nv">$FTP_PASSWORD</span> ftp://programiraj.ba
<span class="nb">echo</span> <span class="s2">&#34;Upload all files from home/public to programiraj.ba using lftp&#34;</span>
lftp -e <span class="s2">&#34;set ftp:ssl-allow no; mirror -R -P 5 ~/project/home/public /www; quit&#34;</span> -u <span class="nv">$FTP_USERNAME</span>,<span class="nv">$FTP_PASSWORD</span> ftp://programiraj.ba</code></pre></div>
<p>Environment variables $FTP_USERNAME $FTP_PASSWORD are set project on CircleCI.</p>

<p>And that&rsquo;s it every time I change or add new post I just push it on github and it gets publised on my site.</p>

<p>If You have some questions or suggestions I will gladly answer to You.</p>
]]></content>
		</item>
		
		<item>
			<title>First Post</title>
			<link>https://blog.programiraj.ba/posts/first-post/</link>
			<pubDate>Fri, 28 Dec 2018 02:02:20 +0100</pubDate>
			
			<guid>https://blog.programiraj.ba/posts/first-post/</guid>
			<description>Let&amp;rsquo;s try to write down some ideas using this very fast static site generator hugo.
Hugo set up is really easy:
 Download binary for Your OS https://github.com/gohugoio/hugo/releases add it to PATH. More details and other ways to install can be found on https://gohugo.io/getting-started/installing/
 Create new site
hugo new site your-static-site-name.com  Get some theme, I used this theme https://github.com/Track3/hermit. bash cd your-static-site-name.com git submodule add https://github.com/Track3/hermit.git themes/hermit   To create new post run</description>
			<content type="html"><![CDATA[<p>Let&rsquo;s try to write down some ideas using this very fast static site generator <a href="https://gohugo.io" target="_blank">hugo</a>.</p>

<p>Hugo set up is really easy:</p>

<ol>
<li><p>Download binary for Your OS <a href="https://github.com/gohugoio/hugo/releases" target="_blank">https://github.com/gohugoio/hugo/releases</a> add it to PATH. More details and other ways to install can be found on <a href="https://gohugo.io/getting-started/installing/" target="_blank">https://gohugo.io/getting-started/installing/</a></p></li>

<li><p>Create new site</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash">hugo new site your-static-site-name.com</code></pre></div>
<ol>
<li>Get some theme, I used this theme <a href="https://github.com/Track3/hermit" target="_blank">https://github.com/Track3/hermit</a>.
<code>bash
cd your-static-site-name.com
git submodule add https://github.com/Track3/hermit.git themes/hermit
</code></li>
</ol></li>

<li><p>To create new post run</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash">hugo new posts/post_name.md</code></pre></div>
<ol>
<li>Optionally:</li>
</ol>

<p>In order to have comments (discussion) available on site Open account on <a href="https://disqus.com/" target="_blank">disqus</a> and add Your web site to get disqusShortname, set it in config.toml. More info on <a href="https://gohugo.io/content-management/comments/" target="_blank">https://gohugo.io/content-management/comments/</a>. If You Want to track visitors set googleAnalytics <a href="https://gohugo.io/templates/internal/#configure-google-analytics" target="_blank">https://gohugo.io/templates/internal/#configure-google-analytics</a>. My example is in
<a href="https://raw.githubusercontent.com/MirzaAbazovic/programiraj.ba/master/blog/config.toml" target="_blank">config.toml</a></p></li>
</ol>
]]></content>
		</item>
		
	</channel>
</rss>
