1 2 3<!DOCTYPE html> 4<html lang="en"> 5 <head> 6 <meta charset="utf-8"> 7 <title></title> 8 9 <meta name="author" content="Edwin van Leeuwen"> 10 11 <!-- Le HTML5 shim, for IE6-8 support of HTML elements --> 12 <!--[if lt IE 9]> 13
13<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
13 14 <![endif]--> 15 16 <!-- Le styles --> 17 <link href="/assets/themes/twitter/css/1.4.0/bootstrap.css" rel="stylesheet"> 18 <link href="/assets/themes/twitter/css/style.css?body=1" rel="stylesheet" type="text/css" media="all"> 19 20 <!-- Le fav and touch icons --> 21 <!-- Update these with your own images 22 <link rel="shortcut icon" href="images/favicon.ico"> 23 <link rel="apple-touch-icon" href="images/apple-touch-icon.png"> 24 <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png"> 25 <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png"> 26 --> 27 28 <title>Never Mind the Topic</title> 29 <link rel="alternate" type="application/rss+xml" title="RSS" 30 href="http://blackedder.github.io/rss.xml"> 31 32 <!--- MathJax Configuration --> 33
33<script type="text/javascript" 34 src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> 35 </script>
35 36 37 </head> 38 39 <body> 40 41 <div class="topbar"> 42 <div class="fill"> 43 <div class="container"> 44 <a class="brand" href="/">Never Mind the Topic</a> 45 <ul class="nav"> 46 47 48 49 50 51 52 53 54 55 <li><a href="/archive.html">Archive</a></li> 56 57 58 59 60 61 62 63 64 65 66 67 <li><a href="/categories.html">Categories</a></li> 68 69 70 71 72 73 74 75 76 77 <li><a href="/pages.html">Pages</a></li> 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 <li><a href="/tags.html">Tags</a></li> 94 95 96 97 98 99 100 101 </ul> 102 </div> 103 </div> 104 </div> 105 106 <div class="container"> 107 108 <div class="content"> 109 110 111<div class="page-header"> 112<h1> <small>Modelling for fun and profit</small></h1> 113</div> 114 115<div class="row"> 116 <div class="span10" align="justify"> 117 <h1 id="typical-public-transport-times"><a href="/2015/03/13/typical-public-transport-times">Typical public transport times</a></h1> 118<h4 id="march-2015">13 March 2015</h4> 119<p>As mentioned in the <a href="/2015/02/24/public-transport-planning-and-uncertainty">previous post</a> I wanted to spend some time exploring the different trade offs involved with chosing a route by public transport (in London). In that post I highlighted the differences in expected time of arrival, travel time and uncertainty around those times for the train, underground and bus. I have now performed some simulations combining the modes of transports to explore how these differences influence your total travel time.</p> 120 121<figure> 122<img src="/assets/ov_time_examples.svg" alt="Combined transit times of different forms of transport. On the x axis are different combinations, with the 1st row the first type of transport and 2nd the following transport. Y axis gives an overview of the median travel time and the variance around the travel time, with the box indicating the first to third quartile of the data. The lines are the 2 and 98 percent confidence levels." /><figcaption>Combined transit times of different forms of transport. On the x axis are different combinations, with the 1st row the first type of transport and 2nd the following transport. Y axis gives an overview of the median travel time and the variance around the travel time, with the box indicating the first to third quartile of the data. The lines are the 2 and 98 percent confidence levels.</figcaption> 123</figure> 124 125<p>Looking at the figure the most interesting part is the difference in uncertainty. Clearly taking the tube is the most reliable way to get there in a certain time. Bus bus can be faster, but can also be much slower. As a result when choosing a route it is not only important to consider the average time it will take, but also the associated risk of being delayed.</p> 126 127 128 129<p><a href="/2015/03/13/typical-public-transport-times">Post a comment</a></p> 130<h1 id="public-transport-planning-and-uncertainty"><a href="/2015/02/24/public-transport-planning-and-uncertainty">Public transport planning and uncertainty</a></h1> 131<h4 id="february-2015">24 February 2015</h4> 132<p>There are a plethora of public transport route planning apps available for every platform. They often do a good job of providing you with the fastest route, and/or with the route with the least stops. There is one feature that I have always missed though and that is an indication of the risk of taking a route. For example if I miss a connection what will my delay be like? Will I be stuck somewhere for at least half an hour? I plan on posting a series of blog posts exploring this question in more detail. Hopefully starting of with some simulation, theory and then applying it to some actual data on public transport.</p> 133 134<h2 id="background">Background</h2> 135 136<p>I live in London and these posts will all be based on the situation in London. London has its own set of public transport and its own particulars. London has three main types of public transport:</p> 137 138<dl> 139<dt>Trains</dt> 140<dd><p>Reasonable regular time intervals. If you miss one you often have to wait for half an hour. Quite often delayed, but mostly a couple of minutes</p> 141</dd> 142<dt>Underground</dt> 143<dd><p>Every 4-8 of minutes, missing one should only delay you for a bit.</p> 144</dd> 145<dt>Bus</dt> 146<dd><p>Every 10-12 minutes. Officially on a schedule, but in London they donât really follow the schedule. Missing one wonât cost you that much time, but the speed with which you get somewhere is very traffic dependent and so canât really be counted upon to get you somewhere within a specified amount of time.</p> 147</dd> 148</dl> 149 150<p>As one can see these forms of transport have quite different types of uncertainty associated with them. For example bus and then train is quite risky, because the bus might be unex
150pectedly delayed due to heavy traffic and then you might miss your train, causing you to have to wait for a long time. In the next blog posts I will try to explore these different situations and hopefully devise a way to take this risk into account when planning your journey.</p> 151 152 153 154<p><a href="/2015/02/24/public-transport-planning-and-uncertainty">Post a comment</a></p> 155<h1 id="quite-interesting-facts-about-qi-scores"><a href="/2015/01/19/quite-interesting-facts-about-qi-scores">Quite Interesting facts about QI scores</a></h1> 156<h4 id="january-2015">19 January 2015</h4> 157<p>The game show QI has a very interesting <a href="http://qi.com/behind-the-scenes/bts-scoring/">(and well documented)</a> scoring system, but Iâve always felt QI could easily be âgamedâ. For those of you who donât know QI, it is a popular game show with Stephen Fry and Alan Davies. The whole show revolves around quite interesting facts and doesnât take itself seriously (it does take the facts seriously though). Because players lose points when they say the wrong thing I have always had the sneaking suspicion that the game could easily be âgamedâ by not saying anything, so letâs take a closer look at the scores.</p> 158 159<h2 id="relation-between-scoring-and-talking">Relation between scoring and talking</h2> 160 161<p>First, letâs explore whether saying more really results in lower scores. For this I needed the amount people were talking (represented by total number of characters in their sentences) and their scores. Luckily I found <a href="http://qitranscripts.com">this</a> website with transcripts and <a href="http://qiscoreboard.com/">another</a> website with all QI scores from all the episodes. I am afraid the transcripts only cover the first 8 series though, so I donât have all the data. If we plot these and perform a linear regression (with R) we get the following picture:</p> 162 163<figure> 164<img src="/assets/post5_regression.png" alt="Scores as dependent on amount the contestants say. Results from linear regression is shown as a red line" /><figcaption>Scores as dependent on amount the contestants say. Results from linear regression is shown as a red line</figcaption> 165</figure> 166 167<p>Although the relationship is fairly weak, it is (statistically) highly significant, showing that saying less and having a higher score are correlated.</p> 168 169<div id="contentBox" style="margin:0px auto; width:100%" class="clearfix"> 170<div id="column1" style="float:left; margin:0; width:60%;"> 171Next up is my theory that, given that most people score negative points, saying nothing is a winning strategy. For this we only need the data from the scores, so I can use data from all the seasons. The table shows what place you would end up in if you were the silent 5th player. As we can see the percentage of winning is actually quite small (13.8%); most probably you would end up in 2nd or 3rd place. The probability of losing completely is also tiny though, because there have been only a handful of shows where everyone ended up with a positive score. All in all it appears that I was actually wrong. While gaming the system by saying nothing would ensure you wouldn't end in last place, you would also not win that often. 172</div> 173<div id="column2" style="float:left; margin:0; width:10%;"></div> 174<div id="column5" style="float:right; margin:0; width:30%;"> 175 176+------+------------+ 177| Rank | Silent | 178+======+============+ 179| 1 | 13.8% | 180+------+------------+ 181| 2 | 35.2% | 182+------+------------+ 183| 3 | 35.2% | 184+------+------------+ 185| 4 | 13.1% | 186+------+------------+ 187| 5 | 2.7% | 188+------+------------+ 189 190</div> 191</div> 192 193 194<!--Below solves layout issues--> 195 196 197<div class="container"> 198 <div class="row"> 199 <div class="col-md-4"></div> 200 <div class="col-md-4"></div> 201 <div class="col-md-4"></div> 202 </div> 203</div> 204 205 206 207<h2 id="alan-davies-permanent-panel-member">Alan Davies (permanent panel member)</h2> 208 209<figure> 210<img src="/assets/post5_alan.png" /> 211</figure> 212 213<p>Finally, lets take a look at Alanâs performance over time. Since Alan is a permanent member we have his scoring data over time. On the left hand side we have his actually scores, with a running average (black line) and the right hand side the running average of the actual position he ended up in (lower is better). From the scores we can see that he started out quite good, then the scores got lower and slowly started rising again from show 40 onward. If we look at his rank every game there seems to be clear improvement over time. The apparent discrepancy of higher scores in the beginning but worse rankings is presumably because all other players also scored higher in the beginning.</p> 214 215<p>This leads us to a frightening conclusion: if Alan keeps going like this he might end up winning every week :)</p> 216 217<p>
217Hope you found this short overview quite interesting! If people have suggestion on other possible interesting facts in the data feel free let me know :).</p> 218 219 220 221<p><a href="/2015/01/19/quite-interesting-facts-about-qi-scores">Post a comment</a></p> 222<h1 id="piping-to-a-plot"><a href="/programming/2014/12/05/piping-to-a-plot">Piping to a plot</a></h1> 223<h4 id="december-2014">05 December 2014</h4> 224<p>In a <a href="/programming/2014/10/24/plotting-as-easy-as-logging">previous post</a> I talked about an interesting new project I was working on that allowed one to pipe output from another program into a plotting program. The <a href="https://github.com/BlackEdder/plotd">plotting</a> program will interpret the incoming data and plot it to a png file. This allows one to set up a permanent named pipe and listens to that as follows:</p> 225 226<pre><code>mkfifo /path/to/pipe 227plotcli -f < /path/to/pipe</code></pre> 228 229<p>I find this very interesting, because in theory it would mean we can just throw any data at this pipe and have it plot it. Of course there are a number of practical problems with this, that make it not immediately practical. Mainly due to the fact that plots often need a lot of context. I.e. what kind of data is this. How should it be interpreted? Should this data start on a new plot or be part of the previous plot etcetera. Currently with <a href="https://github.com/BlackEdder/plotd">plotcli</a> it is possible to provide this context using plotcli specific messages (i.e. #plotcli -d x,y). This is far from ideal though, because it largely defeats the object of making it very easy to plot any kind of data.</p> 230 231<p>I wonder whether there are easier ways of doing this. It is probably possible to make educated guesses about what is meant most of the time. Still it is notoriously difficult to make a system that is both good at interpreting your meaning and easy to extend/improve. Iâm open to suggestions :)</p> 232 233 234 235<p><a href="/programming/2014/12/05/piping-to-a-plot">Post a comment</a></p> 236<h1 id="multiple-viewpoint-dimensions"><a href="/voting/2014/12/02/multiple-viewpoint-dimensions">Multiple viewpoint dimensions</a></h1> 237<h4 id="december-2014-1">02 December 2014</h4> 238<p>Often political viewpoints are talked about in right-left wing context. In reality voters and parties can rarely be aligned in such a simple (2 dimensional) manner and political viewpoints can be aligned according to many different political axes (<a href="http://en.wikipedia.org/wiki/Political_spectrum#Other_proposed_dimensions">multi-axis political model</a>. The website <a href="http://www.politicalcompass.org/">politcalcompass.org</a> argues for at least two axes: economics and social. In this post we explore the effect of these changes.</p> 239 240<figure> 241<img src="/assets/post4_history.png" alt="Number of viable parties over time under different voting systems. Viewpoints have 2 different axes" /><figcaption>Number of viable parties over time under different voting systems. Viewpoints have 2 different axes</figcaption> 242</figure> 243 244<p>Above we show the voting history for a political model that assumes two axes. As shown the first past the post voting system results in 2-4 viable political parties. In contrast the proportional representation voting system results in 4 viable parties.</p> 245 246<figure> 247<img src="/assets/post4_no_axes.png" alt="Number of viable parties after ten rounds for different number of polical axes." /><figcaption>Number of viable parties after ten rounds for different number of polical axes.</figcaption> 248</figure> 249 250<p>We can also see that the more political axes we assume there are the more sustainable parties proportional voting supports. In contrast, first past the post supports 2 parties almost regardless of the number of axes. You might also notice that the proportional voting on average results in two parties for each political axes.</p> 251 252<h2 id="further-additions-to-the-model">Further additions to the model</h2> 253 254<p>I still want to add two things before I consider the model complete. First, parties that can change their viewpoint over time in response to the will of the voters. Second, the possibility for new political parties to appear in the model. I think both of those are very important features of a realistic model. After that I can spend one or more posts on looking at the results in more detail.</p> 255 256 257 258<p><a href="/voting/2014/12/02/multiple-viewpoint-dimensions">Post a comment</a></p> 259<h1 id="plotting-as-easy-as-logging"><a href="/programming/2014/10/24/plotting-as-easy-as-logging">Plotting as easy as logging</a></h1> 260<h4 id="october-2014">24 October 2014</h4> 261<p>Iâve been frustrated with plotting for a number of years now. I mainly use plotting during simulations and it always feels to me like it should be as easy as logging some numbers to the command line. This frustration first let me to develop <a href="https://gitorious.org/realtimeplot/">RealTimePlot</a>, which is a C++ library that makes it straightforward to plot data with only a couple of lines if code. Still this left me slightly frustrated. Mostly because it was still easier to log some values to the console than to plot them because the console is always there. This was not helped by the fact that I undertook a major refactoring of the code and never finished that.</p> 262 263<p>Recently Iâve gotten very interested in the D programming language so naturally I thought about writing another plotting library. This has resulted in <a href="https://github.com/BlackEdder/plotd">plotcli</a>. Plotcli is the result of many years of frustration and I hope to have finally cracked it by adhering to the unix philosophy. Instead of a library, plotcli is a standalone command line program that you feed data into. It will then try to plot this data in a sensible way. You can also provide it with information on the structure of your data either via command line switches or commands in the data file. See the <a href="https://github.com/BlackEdder/plotd/wiki">wiki</a> for some examples.</p> 264 265<p>Some pros of using a standalone program vs library:</p> 266 267<ul> 268<li>On multi core machines you automatically gain parallelism</li> 269<li>Data is still around, making it easy to (re)plot it in different ways without rerunning the simulation</li> 270<li>No need to create bindings for different languages</li> 271</ul> 272 273<p>Plotcli is still in quite early stages of development, but it is shaping up well and bug reports/fixes and feature requests would be highly appreciated.</p> 274 275 276 277<p><a href="/programming/2014/10/24/plotting-as-easy-as-logging">Post a comment</a></p> 278<h1 id="rational-voting"><a href="/voting/2014/09/27/rational-voting">Rational voting</a></h1> 279<h4 id="september-2014">27 September 2014</h4> 280<p>In the <a href="/voting/2014/09/22/proportional-representation-vs-first-past-post-voting">previous post</a> I gave a quick overview of the long term difference of proportional representation vs first past the post voting systems and I showed that first past the post voting systems result in less viable political parties in the long run. This is the because in first-past-the-post voting only the larger parties have any chance of getting any power. The way I incorporated that in the previous post was a bit of a hack, where I just assumed that this was the case, without any reasoning. Here I will look at why this is indeed the case for any rational voter.</p> 281 282<h2 id="what-does-a-rational-voter-want">What does a rational voter want?</h2> 283 284<figure> 285<img src="/assets/vote_power.png" alt="Black points are the relative number of votes each party gets. Red points the number of votes weighted by the resulting power." /><figcaption>Black points are the relative number of votes each party gets. Red points the number of votes weighted by the resulting power.</fig
285caption> 286</figure> 287 288<p>Naively one would think that what a voter wants is to vote for the party that most agrees with them, but ultimately a voter is interested in the power balance over all parties. Therefore, a rational voter should vote for the party that brings the balance of power most in line with his/hers viewpoint. This is also why people will vote for parties that wield more power, because those partiesâ influence on the balance of power is greater. The easiest way to define the balance of power is the average viewpoint of all parties weighted with their power.</p> 289 290<figure> 291<img src="/assets/post3_voting_history.png" alt="Number of viable parties over time under different voting systems." /><figcaption>Number of viable parties over time under different voting systems.</figcaption> 292</figure> 293 294<p>If we rerun the simulation using this measurement, we again get similar results in that proportional voting supports more parties than first past the post voting. One important factor though is how much people feel their vote is worth. If their vote is not worth much then also with proportional voting you only end up with two parties. Interestingly enough this is because people will only vote the fringe parties. This is because if the political power lies slightly to your right then the best way to influence it is to vote far left, because that will switch average power further to the left than voting for a party closer to you.</p> 295 296<figure> 297<img src="/assets/post3_influence.png" alt="Number of viable parties dependent on the amount of influence a voter thinks he/she has." /><figcaption>Number of viable parties dependent on the amount of influence a voter thinks he/she has.</figcaption> 298</figure> 299 300<p>I have the feeling that this result is an artifact of only using one political axis. With more axes it become more difficult/impossible for this tug of war to happen, so we will have a closer look at this in the next post.</p> 301 302 303 304<p><a href="/voting/2014/09/27/rational-voting">Post a comment</a></p> 305<h1 id="proportional-representation-vs-first-past-post-voting"><a href="/voting/2014/09/22/proportional-representation-vs-first-past-post-voting">Proportional representation vs First past post voting</a></h1> 306<h4 id="september-2014-1">22 September 2014</h4> 307<p>In this post I will explore the different voting systems via simulation. For this we need voters and parties and then we simulate the number of votes each party from election to election. Naively we would expect voters to vote for the party whose viewpoint is the closest to the viewpoint of the voter. For simplicity we will assume here that a viewpoint is basically a simple variable defining their position on the political spectrum (far left to far right). Later we will look more into multidimensional viewpoints.</p> 308 309<h3 id="voting">Voting</h3> 310 311<figure> 312<img src="/assets/one_vote.png" alt="Single round of voting assuming everyone votes for the party that most closely aligns with their own viewpoint. Dots are the relative amount of votes for each party, The line shows the number of people with a certain viewpoint." /><figcaption>Single round of voting assuming everyone votes for the party that most closely aligns with their own viewpoint. Dots are the relative amount of votes for each party, The line shows the number of people with a certain viewpoint.</figcaption> 313</figure> 314 315<p>Here Iâve shown the outcome of one round of voting, where everyone votes for the party whose viewpoint is closest to theirs. Interestingly, one of the biggest parties is on the fringe here, because all the voters that are further to the left vote for that party. This means that even though most voters are central, âfringeâ parties can get a relatively large presence because they cater to a wider spectrum of the political landscape.</p> 316 317<h3 id="taking-power-into-account">Taking power into account</h3> 318 319<figure> 320<img src="/assets/power_votes.png" alt="Different possible relationships between relative number of votes of a party and the amount of power a party has" /><figcaption>Different possible relationships between relative number of votes of a party and the amount of power a party has</figcaption> 321</figure> 322 323<p>The previous example assumed that people will actually just vote on the party whose viewpoint is most closely aligned with their own viewpoint. Of course people will also take into account whether the party they vote for has a lot of power/influence. Here is were the difference between the voting systems come in. Illustrated above are some possible scenarios. 1) Peopleâs decision is completely independent of the amount of votes 2) The power of a given party is proportional to the number of votes they received 3) Parties with high
323number of votes have a disproportionally large amount of power. In a pure first past the post system only the party with the most votes has any power. Here I chose a less extreme form of first past the post. This represents the fact that even if only the largest party has any power, when you vote you will not know which party will end up the larger party. Only that the currently larger parties are more likely to become the largest party after voting.</p> 324 325<h3 id="number-of-parties">Number of parties</h3> 326 327<figure> 328<img src="/assets/weighted_voting_history.png" alt="Simulating the number of parties under each system over time" /><figcaption>Simulating the number of parties under each system over time</figcaption> 329</figure> 330 331<p>If we now simulate the number of parties over a couple of elections we will see that indeed the first past the post system ends up with the least (two) amount of parties. Proportional representation ends up with a higher number of parties. The exact amount of parties is dependent on the mix of parties (and their viewpoints) present at the start.</p> 332 333<h3 id="possible-next-posts">Possible next posts</h3> 334 335<p>In this post I had a quick look at different democratic voting systems and their results for the number of parties present over time. I hope to take a more in depth look over different possible aspects in future posts. Some things I want to look at are:</p> 336 337<ul> 338<li><a href="/voting/2014/09/27/rational-voting">How should rational people vote?</a> Here I just assumed people would weigh their viewpoint by the amount of influence a party will have. It should be possible though to be more exact in how people would weigh these different factors.</li> 339<li>Evolving parties. Parties change their viewpoint over time in response to voters. This should also influence voting behaviour.</li> 340<li><a href="/voting/2014/12/02/multiple-viewpoint-dimensions">Multidimensional political axes</a>. For simplicity I assumed one political axis here (i.e. left to right wing). In reality the world is not that simple though.</li> 341</ul> 342 343 344 345<p><a href="/voting/2014/09/22/proportional-representation-vs-first-past-post-voting">Post a comment</a></p> 346<h1 id="why-did-i-start-this-blog"><a href="/2014/09/19/why-did-i-start-this-blog">Why did I start this blog?</a></h1> 347<h4 id="september-2014-2">19 September 2014</h4> 348<p>Every so often a discussion erupts on Slashdot discussing the merits of democracy. Part of this discussion always focusses on the two party system and its short comings. As someone from the Netherlands where we have at least 5 viable parties this part of the discussion always fascinated me. Especially now I live in the UK, where there are basically three parties. The main theory for the cause of this difference is a first past the post voting system versus proportional representation.</p> 349 350<p>With my background in modelling biological behaviour my natural reaction to hearing theories is to write down a model that captures those theories (weird!). Which started me thinking that it would be interesting to do some modelling and explore the different voting systems in some more depths purely to satisfy my own curiosity, but I could never find the motivation to actually do this. Hopefully having this blog and the imaginary future readers will motivate me to actually move forward.</p> 351 352 353 354<p><a href="/2014/09/19/why-did-i-start-this-blog">Post a comment</a></p> 355 356 </div> 357 <div class="span4"> 358 <h1><small>Edwin van Leeuwen</h1> 359 </div> 360</div> 361 362 363 </div> 364 365 <footer> 366 <p>© Edwin van Leeuwen 2012 367 with help from <a href="http://jekyllbootstrap.com" target="_blank" title="The Definitive Jekyll Blogging Framework">Jekyll Bootstrap</a> 368 and <a href="http://twitter.github.com/bootstrap/" target="_blank">Twitter Bootstrap</a> 369 </p> 370 </footer> 371 372 </div> <!-- /container --> 373 374 375 </body> 376</html> 377
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.