<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>The poor man's math blog</title>
    <description>By Stefano Maggiolo</description>
    <link>http://blog.poormansmath.net</link>
    <atom:link href="http://blog.poormansmath.net/feed.xml" rel="self" type="application/rss+xml" />
    
      <item>
        <title>Some photos and statistics</title>
        <description>&lt;p&gt;I recently posted 120 of what I considered the best photos I took on Facebook. Here’s some stats about how much my friends liked them.&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;Ideally I posted one photo per day, named from 1 to 120; but life happened and I had a hiatus of a few weeks. Regardless, let’s assume that each day there was a photo, so the index is also a time quantity.&lt;/p&gt;

&lt;p&gt;We can start with some high level stats: there were 867 reactions, that is a little bit more than 7 per photo. While posting, I got the impression the novelty wore off after a while, and friends started to get tired. Indeed, a simple linear regression shows a negative coefficient.&lt;/p&gt;

&lt;figure&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/reactions_per_photo_ordered.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/reactions_per_photo_ordered.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    Reactions per photo
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;figure class=&quot;right&quot; style=&quot;width: 500px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/reactions_per_photo.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_500_reactions_per_photo.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    Photos with certain number of reactions
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;If we group by number of reactions, we the histogram on the right.&lt;/p&gt;

&lt;p&gt;It looks like a decent Poisson distribution. Indeed, we can assume reactions happen only on the day each photo was posted, and so the number of reactions per day should indeed be a Poisson. Of course, this also assumes reactions are independent on the quality of the photo… maybe that’s a good assumption.&lt;/p&gt;

&lt;p&gt;The top photo has 25 reactions, and other 7 have 15 or more reactions. Here they are, in order (left to right, top to bottom):&lt;/p&gt;

&lt;figure style=&quot;width: 650px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/best_photos.jpg&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_650_best_photos.jpg&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    Photos with the most reactions
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;Speaking of low-lights instead, here are the 5 photos with only one reactions (we will soon talk about that):&lt;/p&gt;

&lt;figure style=&quot;width: 650px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/worst_photos.jpg&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_650_worst_photos.jpg&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    Photos with only one reaction
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;Overall, I think it’s fair judgement. There are some weirdness: the top right best photo (Hallgrimskirkja, in Reykjavik) has probably many laughing reactions due to the witty pun I added as comment, rather than due to the photo itself. On the other hand, I would have expected the first worst photo to be appreciated more.&lt;/p&gt;

&lt;p&gt;So, why no photo has no reactions? Well, let’s see a histogram of how many people liked a certain number of photos:&lt;/p&gt;

&lt;figure&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/reactions_per_person.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/reactions_per_person.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    People with certain number of reactions
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;You can recognize a pretty good power law (alpha = 1.8), but also some outlier; the person that liked 112 photos (93%) as you can imagine, is my mum. The most likely explanation for the remaining 8 is some bug in Facebook’s news feed.&lt;/p&gt;

&lt;p&gt;The reason for this silly post was just to try out &lt;a href=&quot;http://seaborn.pydata.org&quot;&gt;seaborn&lt;/a&gt;, a plotting library for Python on top of matplotlib. It makes easy to plot a limited set of graph types, and in addition has a decent preset style: that is to say, exactly the opposite of matplotlib. So I couldn’t really finish without using the coolest graph type it allows: violin plots.&lt;/p&gt;

&lt;p&gt;I split the 120 photos in 9 categories, here listed from the most frequent to the least: architecture, cityscapes, landmarks, landscapes, people, close-ups, animals, nature, and textures (landscapes and nature are similar, but the former has some human-sourced component). And here’s the reactions in this sets behaved:&lt;/p&gt;

&lt;figure&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/reactions_per_tag.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/reactions_per_tag.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    Reactions per tag
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;Beautiful. Animals and nature are the overall favourites, which again shows: the Internet loves its kittens.&lt;/p&gt;

</description>
        <pubDate>Fri, 12 Jan 2018 00:00:00 +0000</pubDate>
        <link>http://blog.poormansmath.net/some-photos-and-statistics/</link>
        <guid isPermaLink="true">http://blog.poormansmath.net/some-photos-and-statistics/</guid>
      </item>
    
      <item>
        <title>Filling a void</title>
        <description>&lt;p&gt;In the &lt;a href=&quot;http://data.london.gov.uk/&quot;&gt;increasingly&lt;/a&gt; populated &lt;a href=&quot;http://www.theguardian.com/cities/gallery/2014/oct/28/london-life-mapped-data-visualisation-graphics&quot;&gt;scene&lt;/a&gt; of &lt;a href=&quot;http://mappinglondon.co.uk/&quot;&gt;London mapping&lt;/a&gt; there was still something very basic missing.&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;London boroughs constitutes an important part of the administration of the city: they are responsible for many local services: school, social services (including housing), waste management, parks, and have a say also in the public transport. To fund them, resident pay a council tax which varies a lot between boroughs. Also, the elections for the borough council are the only one where non-citizen can vote, given their local scope.&lt;/p&gt;

&lt;figure class=&quot;right&quot; style=&quot;width: 150px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/london_boroughs.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_150_london_boroughs.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    London borough map on Wikipedia
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;One problem is that as of yesterday I had no idea how most boroughs were placed around London. Yes, you can easily find maps like the one on the right &lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_London_boroughs&quot;&gt;on Wikipedia&lt;/a&gt;, but it is hardly informative: it is definitely too hard to navigate it without any landmark. An image search for &lt;a href=&quot;https://www.google.co.uk/search?q=london+borough+map&amp;amp;tbm=isch&quot;&gt;london borough map&lt;/a&gt; also gives almost always highly stylized maps that do not show much more than just the boroughs’ boundaries.&lt;/p&gt;

&lt;figure class=&quot;left&quot; style=&quot;width: 300px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/london_borough_tube.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_300_london_borough_tube.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    London borough map with tube stations
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;And honestly, there are not a lot of landmarks I would recognize outside of zone 2… wait, there are some: the tube stations! I rarely go outside zone 2 even with the tube, but I got used anyway to most names just by looking at the line maps while traveling. And this must be true for many people, because when I type “london borough map” on Google, on of the first completions it suggests is “with tube stations”. Sadly, I could not find any map with this information, so I created it! You can see it on the left as a png (click to enlarge and download), or get the &lt;a href=&quot;/files/london_borough_tube.pdf&quot;&gt;pdf file&lt;/a&gt;. The main source is of course Tfl’s wonderful &lt;a href=&quot;http://www.tfl.gov.uk/cdn/static/cms/documents/london-rail-and-tube-services-map.pdf&quot;&gt;tube and rail map&lt;/a&gt;, and just a couple of hours of Inkscape did the trick.&lt;/p&gt;

</description>
        <pubDate>Mon, 11 May 2015 00:00:00 +0000</pubDate>
        <link>http://blog.poormansmath.net/filling-a-void/</link>
        <guid isPermaLink="true">http://blog.poormansmath.net/filling-a-void/</guid>
      </item>
    
      <item>
        <title>The time it takes to change the time</title>
        <description>&lt;p&gt;You might remember from last year &lt;a href=&quot;/how-much-is-time-wrong-around-the-world/&quot;&gt;my map showing the difference between solar time and standard time&lt;/a&gt;; you might because it was by far the most shared content I created, and somebody even uploaded it to Wikipedia for the &lt;a href=&quot;http://en.wikipedia.org/wiki/Time_zone&quot;&gt;time zone&lt;/a&gt; article. But with great power comes great responsibility (…); in this case it means keeping the map up to date as the whims of the time regulators change. You would think this is a rare event, but when you consider the 200 or so sovereign states in the world, and the quadratic number of possible conflicts between them, it becomes a frequent event.&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;Indeed, the &lt;strong&gt;triggering event&lt;/strong&gt; that prompted me to draw a new version wasn’t the bad color choice of the first attempt (for many people, green and red do not play well together), neither the small mistakes in the zone divisions, and not even some political faux pas (not marking Taiwan in the same way as most other sovereign states). After all, the map was drawn on top of an existing one found on Wikipedia, with just minor modifications apart from the gradients.&lt;/p&gt;

&lt;p&gt;The real reason is that just a &lt;a href=&quot;http://en.wikipedia.org/wiki/Time_in_Russia#2014_zone_boundary_changes&quot;&gt;few months&lt;/a&gt; after releasing my map, &lt;strong&gt;Russia&lt;/strong&gt; decided to &lt;strong&gt;change the time in most of the country&lt;/strong&gt;. Since Russia extends to about 3.5% of the world’s area and 11.5% of the emerged lands area, the issue was too obvious to ignore.&lt;/p&gt;

&lt;p&gt;Apart from this big change, the new map reflects that some territories in &lt;strong&gt;Ukraine&lt;/strong&gt; and &lt;strong&gt;Georgia&lt;/strong&gt; follow Moscow time instead of their countries’ timezone, and the &lt;a href=&quot;http://en.wikipedia.org/wiki/Quintana_Roo#Time_zone&quot;&gt;introduction&lt;/a&gt; of the “Southeast” timezone (permanent UTC-05:00) in Quintana Roo, &lt;strong&gt;Mexico&lt;/strong&gt;. Continental Mexico is about 30 degrees of longitude wide, from Tijuana to Cancun, so two timezones would make sense, instead it has four!&lt;/p&gt;

&lt;figure class=&quot;left&quot; style=&quot;width: 450px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/SolarTimeVsStandardTimeV2.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_450_SolarTimeVsStandardTimeV2.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    Solar time vs standard time
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;Overall, the map is still skewed towards the red (which means that the solar noon is later in the day), and most of what &lt;a href=&quot;/how-much-is-time-wrong-around-the-world/&quot;&gt;could be observed&lt;/a&gt; from the first version is still valid. In particular, for the joy of reddit commentators, &lt;strong&gt;China&lt;/strong&gt; is still very red.&lt;/p&gt;

&lt;p&gt;Sadly, one change did not happen: &lt;strong&gt;Australia&lt;/strong&gt; still refuses to make &lt;strong&gt;Central Western Time&lt;/strong&gt;, aka the awesome &lt;a href=&quot;http://en.wikipedia.org/wiki/UTC%2B08:45&quot;&gt;UTC+08:45&lt;/a&gt; timezone, official. You see how the difference between Western and Central Australia is a whole hour and a half? This is not a big problem because no people live on the transition zone, apart from a very narrow strip of 350km along the southern coast, on the road between Perth and Adelaide, where about 200 proud people live on their own time.&lt;/p&gt;

&lt;p&gt;If made official, it would be the timezone with the &lt;strong&gt;fewer residents&lt;/strong&gt; (followed by UTC+10:30, Lord Howe Island, with about 360, and UTC+12:45, Chatham Islands, with about 600), apart from the ephemeral UTC-12:00 timezone: only a few birds inhabit the two US islands of Howland and Baker, that are the only emerged lands in it, with their whopping 4 squared kilometers. But, since they are uninhabited, nobody ever said what time they should follow, and they are unofficially UTC-12:00 just because they happen to be at the correct longitude..&lt;/p&gt;

&lt;p&gt;I mentioned that 90 minutes is an unusual large difference between neighboring timezones, since of course the usual is one hour. But there are many places with much larger differences: these always involve China, thanks to its single, big, timezone. The worst offender here is the &lt;strong&gt;90 kilometers border&lt;/strong&gt; between Afghanistan (UTC+04:30) and China (UTC+08:00): a difference of three hours and a half!&lt;/p&gt;

&lt;h3 id=&quot;how-to-draw-a-map&quot;&gt;How to draw a map&lt;/h3&gt;

&lt;p&gt;Drawing the first version of this map was a very long process done more or less by hand, modifying the source of an existing SVG file, and I definitely did not want to go over the same process again (and again when something else changes). So I &lt;a href=&quot;http://xkcd.com/1205/&quot;&gt;blatantly&lt;/a&gt; ignored &lt;a href=&quot;http://xkcd.com/1319/&quot;&gt;xkcd&lt;/a&gt; and proceeded to &lt;strong&gt;Create the Tool&lt;/strong&gt; that would Create the Map for me. The real value of the tool for the future depends on the availability of up to date data, still I can trick myself into thinking I saved time.&lt;/p&gt;

&lt;p&gt;All the tools I will mention in the following can be found in the &lt;a href=&quot;https://github.com/stefano-maggiolo/solar-time-vs-standard-time&quot;&gt;solar time vs standard time repository&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Looking at a map, people often do not realize how many &lt;strong&gt;ingredients&lt;/strong&gt; combine to create it;  we take a lot of things for granted. This map has probably a sub-average number of ingredients, though we can see:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;timezone boundaries over the sea (approximate, as the territorial water boundaries are too intricate to draw);&lt;/li&gt;
  &lt;li&gt;land/water and country boundaries;&lt;/li&gt;
  &lt;li&gt;timezone territories (which are a different hierarchy than countries: a country might have more than one timezone, and a timezone might encompass more countries);&lt;/li&gt;
  &lt;li&gt;cities coordinates;&lt;/li&gt;
  &lt;li&gt;labels of:
    &lt;ul&gt;
      &lt;li&gt;countries;&lt;/li&gt;
      &lt;li&gt;cities;&lt;/li&gt;
      &lt;li&gt;timezones.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Luckily, there are &lt;strong&gt;datasets&lt;/strong&gt; available for most of these; some with a unique source, maybe slightly out of date, some with more sources. It turns out that choosing the best in terms of accuracy and license is an important step when creating a map programmatically. In our case, timezones come from &lt;a href=&quot;http://efele.net/maps/&quot;&gt;Eric Muller’s website&lt;/a&gt;, and the same for country boundaries (these in turns come from the &lt;a href=&quot;http://en.wikipedia.org/wiki/Federal_Information_Processing_Standards&quot;&gt;FIPS&lt;/a&gt; dataset). Homogeneity is an important quality, and since timezone boundaries is a very rare dataset, it made sense to take the country boundaries from Eric as well. Coordinates of major cities (with other info useful to select whose to show) instead came from the &lt;a href=&quot;http://techcenter.jefferson.kctcs.edu/data/&quot;&gt;ESRI datasets&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But getting the data is just the first step. The second is not very hard: draw the SVG with the &lt;strong&gt;boundaries&lt;/strong&gt;. This involves some templating to create the file and most importantly translating latitude and longitude into pixel coordinates (that is, the choice of a projection). Again, I was constrained to a rectilinear projection because drawing the gradients was much simpler, so I sticked with the Miller.&lt;/p&gt;

&lt;p&gt;Third step, &lt;strong&gt;writing the labels&lt;/strong&gt;. Here there is an important choice: is it faster to design an algorithm that tries to place the labels automatically, or to place them semi-manually? The first option is not that easy: I would frame it as an optimization problem, where the function to optimize depends on the distance between the labels and what they refer to, on their size, and on how much they overlap, but I admit I did not try this. Instead, the semi-manual approach consists in placing the labels in a reasonable position (at the centroid of the country, and anchored to the coordinates of the city), and then to tweak the labels that need tweaking.&lt;/p&gt;

&lt;p&gt;Fourth step is drawing the &lt;strong&gt;labels and lines of the timezones&lt;/strong&gt;. For the labels, I just wrote a list of positions I wanted, so again very manual. For the lines, in theory a good approximation could be just drawing 24 equispaced meridians, but the map becomes very hard to read. To make easier the job of drawing a lot of polylines on a map, I wrote a very simple helper tool based on Maps API, that allows to draw directly on the map and retrieve the coordinates of the vertices in a JSON format.&lt;/p&gt;

&lt;p&gt;Finally, the last step: &lt;strong&gt;data correction&lt;/strong&gt;! Eric Muller’s data sadly is not completely up to date. Some fixes are easy (just changing the offset of a few timezones), others are not so simple, and I eventually decided to just use GIMP to draw over the final image generated by the program (which explains the GIMP file in the repository). Shifting the center of the map so that the cut point is not over Siberia was also done in postprocessing; in theory it should be easy to do at the projection stage, but the source datasets already split all lands on the 180 meridian, which made more convenient to use the same cut point in the projection.&lt;/p&gt;

&lt;!-- DO NOT EDIT BELOW THIS LINE --&gt;
&lt;hr /&gt;

&lt;h3 id=&quot;see-also&quot;&gt;See also&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;/my-two-cents-on-the-daylight-saving-time/&quot;&gt;My two cents on the daylight saving time&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/how-much-is-time-wrong-around-the-world/&quot;&gt;How much is time wrong around the world?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/emotional-time/&quot;&gt;Global time, emotional time, and the annoyance of DST&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
        <pubDate>Tue, 17 Feb 2015 00:00:00 +0000</pubDate>
        <link>http://blog.poormansmath.net/the-time-it-takes-to-change-the-time/</link>
        <guid isPermaLink="true">http://blog.poormansmath.net/the-time-it-takes-to-change-the-time/</guid>
      </item>
    
      <item>
        <title>A new year</title>
        <description>&lt;p&gt;A new year began, and I’ve been working on a new home and a new design for &lt;em&gt;The poor man’s math blog&lt;/em&gt;.&lt;/p&gt;

&lt;!--more--&gt;

&lt;figure class=&quot;right&quot; style=&quot;width: 200px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/old-wordpress-blog.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_200_old-wordpress-blog.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    My old home page.
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;I started this blog &lt;strong&gt;six years ago&lt;/strong&gt;; I admit it is not a great achievement as the frequency has always been from low to zero, but I put a substantial amount of effort and time in it, and occasionally has been quite rewarding. The problem is that these moments are exactly those in which I created some issues to our beloved &lt;em&gt;macchinisti&lt;/em&gt;, the administrators of the student-run server that hosted my blog until yesterday. Thanks a lot to them for bearing with me!&lt;/p&gt;

&lt;p&gt;Because of this, I decided to give them a break and my blog a &lt;strong&gt;more stable home&lt;/strong&gt;, on GitHub. To avoid making this post completely useless, I will describe my set up, in case it is of interest to anybody.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub&lt;/strong&gt; offers free hosting for static pages at addresses like &amp;lt;username&amp;gt;.github.io, based on the content of a repository with the same name. Not only this, but it also treats some specific files in that repository in a special way, think of if “compiling” the repository to a static website. For reference, &lt;a href=&quot;http://github.com/stefano-maggiolo/stefano-maggiolo.github.io&quot;&gt;this is the repository&lt;/a&gt; for this site.&lt;/p&gt;

&lt;p&gt;I acquired &lt;a href=&quot;http://poormansmath.net/&quot;&gt;poormansmath.net&lt;/a&gt; some time ago, but it was not possible to use it in my previous home because I didn’t own the &lt;strong&gt;domain&lt;/strong&gt;; luckily, this is true for GitHub. The first special file we will see is indeed &lt;a href=&quot;https://github.com/stefano-maggiolo/stefano-maggiolo.github.io/blob/master/CNAME&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;CNAME&lt;/code&gt;&lt;/a&gt;, that tells GitHub the domain you want to use for the site.&lt;/p&gt;

&lt;p&gt;Speaking about the compilation to static pages, GitHub uses &lt;strong&gt;&lt;a href=&quot;http://jekyllrb.com/&quot;&gt;Jekyll&lt;/a&gt;&lt;/strong&gt;, I think triggered by the presence of a &lt;a href=&quot;https://github.com/stefano-maggiolo/stefano-maggiolo.github.io/blob/master/_config.yml&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;_config.yml&lt;/code&gt;&lt;/a&gt; file. Jekyll allows a limited template engine to run on your file, and a &lt;a href=&quot;http://daringfireball.net/projects/markdown/&quot;&gt;Markdown&lt;/a&gt; interpreter on your posts. The advantage over a completely static site is that a lot of boilerplate can be factored out in templates, and you can write posts in Markdown instead than in raw HTML, which is nice. I forked a project I liked, from &lt;a href=&quot;https://github.com/barryclark/jekyll-now&quot;&gt;Barry Clark&lt;/a&gt;, and built on that.&lt;/p&gt;

&lt;p&gt;I changed some &lt;a href=&quot;https://github.com/stefano-maggiolo/stefano-maggiolo.github.io/commit/cab3a88598b2d9348885a3ea28907e197f229bc2&quot;&gt;typeface&lt;/a&gt;, added &lt;a href=&quot;https://github.com/stefano-maggiolo/stefano-maggiolo.github.io/commit/9c7ed4c2c4c3e0afa8c20a722d45b91dcb852ab8&quot;&gt;semantic information&lt;/a&gt; for crawlers, &lt;a href=&quot;https://github.com/stefano-maggiolo/stefano-maggiolo.github.io/commit/7bd00a5aa75f2be8bf8f7daf17d08e35c051645f&quot;&gt;sharing buttons&lt;/a&gt;, and a very simple &lt;a href=&quot;https://github.com/stefano-maggiolo/stefano-maggiolo.github.io/commit/e99079cb4390b11123c224278b847630320a4547&quot;&gt;lightbox-like image viewer&lt;/a&gt;. This all within GitHub’s compilation with Jekyll. I need to specify this, because Jekyll in general is quite versatile, and you can add new functionalities in Ruby. But, of course, running untrusted code on your server is complicated, so GitHub restrict the compilation to a safe subset of Jekyll.&lt;/p&gt;

&lt;p&gt;But I added also a couple of features outside of Jekyll. The first is &lt;strong&gt;commenting&lt;/strong&gt;: the way to add it to a static site is to use an external service, and I chose &lt;a href=&quot;http://disqus.com&quot;&gt;Disqus&lt;/a&gt;. The second is a &lt;a href=&quot;https://github.com/stefano-maggiolo/stefano-maggiolo.github.io/commit/360ee5469cb1ef3ae89908973c33118b6e2e81c7&quot;&gt;custom script&lt;/a&gt; to append to each post a list of related posts.&lt;/p&gt;

&lt;p&gt;The actual export of posts and comments was a bit painful. You can export them from Wordpress, and try to convert them in Markdown, but a lot of things had to be revised manually. This is where &lt;a href=&quot;http://emacsrocks.com/&quot;&gt;Emacs rocks&lt;/a&gt;: powerful regular expressions, even across files, the awesome multiple cursors feature, and keyboard macros, all of them made the job much faster.&lt;/p&gt;

&lt;!-- DO NOT EDIT BELOW THIS LINE --&gt;
&lt;hr /&gt;

&lt;h3 id=&quot;see-also&quot;&gt;See also&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;/wordpress-upgrade/&quot;&gt;WordPress upgrade&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
        <pubDate>Mon, 26 Jan 2015 00:00:00 +0000</pubDate>
        <link>http://blog.poormansmath.net/a-new-year/</link>
        <guid isPermaLink="true">http://blog.poormansmath.net/a-new-year/</guid>
      </item>
    
      <item>
        <title>Le parole che caratterizzano un’epoca</title>
        <description>&lt;p&gt;“Le parole sono importanti!”, tuonava Michele Apicella alla giornalista di Palombella rossa, colpevole di usare espressioni come “kitsch”, “alle prime armi”, “cheap”. [Continua sul &lt;a href=&quot;http://www.ilpost.it/stefanomaggiolo/2014/10/17/le-parole-che-caratterizzano-unepoca/&quot;&gt;Post&lt;/a&gt;.]&lt;/p&gt;

</description>
        <pubDate>Fri, 17 Oct 2014 00:00:00 +0000</pubDate>
        <link>http://blog.poormansmath.net/le-parole-che-caratterizzano-unepoca/</link>
        <guid isPermaLink="true">http://blog.poormansmath.net/le-parole-che-caratterizzano-unepoca/</guid>
      </item>
    
      <item>
        <title>If it looks like a word, it is a word one third of the time</title>
        <description>&lt;p&gt;With the &lt;a href=&quot;/if-it-looks-like-a-words-then-it-is-a-word/&quot;&gt;last post&lt;/a&gt;, we looked at words of three letters in the Google corpora for six languages, to understand which language has the most three-letter words. But our original question was which one has the most ratio of words among trigrams that “look like” real words, and today we are going to answer that question.&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;Defining what looks like a real word might be difficult, because the answer is ultimately subjective, but we can again perform a simple statistical computation to get a good enough approximation.&lt;/p&gt;

&lt;p&gt;I decided to define that a trigram &lt;em&gt;abc&lt;/em&gt; looks like a word if:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;the trigram &lt;em&gt;abc&lt;/em&gt; occurs in any part of any word;&lt;/li&gt;
  &lt;li&gt;the bigram &lt;em&gt;ab&lt;/em&gt; occurs as the starting part of any word;&lt;/li&gt;
  &lt;li&gt;the bigram &lt;em&gt;bc&lt;/em&gt; occurs as the ending part of any word;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We could use again the Google corpora, limiting ourself to “common” words, but since the definition uses occurrences in &lt;em&gt;any&lt;/em&gt; words, it should be enough to look in a dictionary. Also, to make everything a little more robust, I require that there are at least three occurrences of the trigram or bigram within the dictionary, not only one.&lt;/p&gt;

&lt;p&gt;Using the script extract.py in &lt;a href=&quot;https://gist.github.com/stefano-maggiolo/f8ddab487ab7ba4bd204&quot;&gt;this GitHub gist&lt;/a&gt;, we construct for each language a list of trigrams that look like words, starting from the standard dictionaries provided with Ubuntu. These are the number of such trigrams by language.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Language&lt;/th&gt;
      &lt;th&gt;Trigrams that look like words&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;American English&lt;/td&gt;
      &lt;td&gt;3364&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;British English&lt;/td&gt;
      &lt;td&gt;3366&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;German&lt;/td&gt;
      &lt;td&gt;2492&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Spanish&lt;/td&gt;
      &lt;td&gt;2065&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Italian&lt;/td&gt;
      &lt;td&gt;911&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;French&lt;/td&gt;
      &lt;td&gt;1911&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;English has the most of these trigrams, followed by German, Spanish, French, and Italian. The variance is very high; judging from my knowledge of the two extremes (English and Italian), I can argue that Italian is more strict in the order that letters can follow each other (usually alternating consonants and vowels). [&lt;sup id=&quot;fnref:1&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;]&lt;/p&gt;

&lt;p&gt;To obtain the ratios, we just need to use merge.py in the same gist to intersect the list of trigrams with the list obtain via Google nGrams. Here are the results by language.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Language&lt;/th&gt;
      &lt;th&gt;Trigrams looking like words&lt;/th&gt;
      &lt;th&gt;Three-letter words&lt;/th&gt;
      &lt;th&gt;Ratio&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;American English&lt;/td&gt;
      &lt;td&gt;3364&lt;/td&gt;
      &lt;td&gt;1026&lt;/td&gt;
      &lt;td&gt;30%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;British English&lt;/td&gt;
      &lt;td&gt;3366&lt;/td&gt;
      &lt;td&gt;1034&lt;/td&gt;
      &lt;td&gt;31%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;German&lt;/td&gt;
      &lt;td&gt;2492&lt;/td&gt;
      &lt;td&gt;679&lt;/td&gt;
      &lt;td&gt;27%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Spanish&lt;/td&gt;
      &lt;td&gt;2065&lt;/td&gt;
      &lt;td&gt;529&lt;/td&gt;
      &lt;td&gt;26%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Italian&lt;/td&gt;
      &lt;td&gt;911&lt;/td&gt;
      &lt;td&gt;398&lt;/td&gt;
      &lt;td&gt;44%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;French&lt;/td&gt;
      &lt;td&gt;1911&lt;/td&gt;
      &lt;td&gt;615&lt;/td&gt;
      &lt;td&gt;32%&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Apparently, I was wrong! It’s not English that shows a high ratio of three-letter words but… Italian. This of course is mainly due to the much lower number of trigrams in Italian. It is also interesting to see that German is close to be the language with the lowest ratio despite being the one with the most frequent usage of three-letter words; but we already saw that that is because its most frequent three-letter words are really frequent.&lt;/p&gt;

&lt;!-- DO NOT EDIT BELOW THIS LINE --&gt;
&lt;hr /&gt;

&lt;h3 id=&quot;part-of-this-series&quot;&gt;Part of this series&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;/if-it-looks-like-a-words-then-it-is-a-word/&quot;&gt;If it looks like a words, then it is a word (?)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/if-it-looks-like-a-word-it-is-a-word-one-third-of-the-time/&quot;&gt;If it looks like a word, it is a word one third of the time&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;footnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot;&gt;
      &lt;p&gt;I wonder if this has any consequence on how easy is to define a crossword in the two languages. Sadly I could not find any good source on this fundamental issue, I think also due to the lack of multilingual crossword authors. The Wikipedia entry shows examples of a Japanese-style grid, which seems very influenced by the stricter alternation of consonants and vowels. By experience, that is also the style of many Italian crosswords, but not necessarily the unique. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Mon, 25 Aug 2014 00:00:00 +0000</pubDate>
        <link>http://blog.poormansmath.net/if-it-looks-like-a-word-it-is-a-word-one-third-of-the-time/</link>
        <guid isPermaLink="true">http://blog.poormansmath.net/if-it-looks-like-a-word-it-is-a-word-one-third-of-the-time/</guid>
      </item>
    
      <item>
        <title>If it looks like a words, then it is a word (?)</title>
        <description>&lt;p&gt;Being born as a &lt;strong&gt;native English speaker&lt;/strong&gt; is a great luck these days. For the simplicity of its grammar and a predominance in the cultural world from the twentieth century onwards, English, or more precisely &lt;a href=&quot;http://en.wikipedia.org/wiki/International_English&quot;&gt;one of its dialect&lt;/a&gt; is the de facto international language, and being able to speak it natively is a huge advantage. If you are like me, instead, no matter how expert you may become, your level of comprehension of the subtleties will always be lower than that of any native speaker, you will always retain at least a bit of your original accent; you’ll never be able to pronounce all the words in the correct way, and there always will be some word you won’t know.&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;Among these, the biggest issue with English is its &lt;a href=&quot;https://www.youtube.com/watch?v=1edPxKqiptw&quot;&gt;inconsistent pronunciation&lt;/a&gt;. Since even native speakers in the same country cannot &lt;a href=&quot;http://en.wikipedia.org/wiki/International_Phonetic_Alphabet_chart_for_English_dialects&quot;&gt;reach an agreement&lt;/a&gt; on &lt;strong&gt;how to pronounce a word&lt;/strong&gt; [&lt;sup id=&quot;fnref:1&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;], you may get away with mistakes by claiming that your weird pronounce is actually used by some native English dialect [&lt;sup id=&quot;fnref:2&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;].&lt;/p&gt;

&lt;p&gt;Something you cannot get away with, though, is the &lt;strong&gt;lexicon&lt;/strong&gt;. English has a &lt;strong&gt;huge lexicon&lt;/strong&gt;. Similar to ancient Romans, English conquered and assimilated, not only people and land but words [[^3]]. I jokingly stated that in English &lt;em&gt;almost any sequence of three letters that look like a word is actually a word&lt;/em&gt;. Is this just a joke or is there some truth behind?&lt;/p&gt;

&lt;p&gt;One could look into a dictionary to find out, patiently looking for all three-letter words. This is a fair strategy, but dictionaries are a &lt;strong&gt;static standardization&lt;/strong&gt; of a living language, not dissimilar to what a picture is to a person. In particular, dictionary curators &lt;a href=&quot;http://en.wikipedia.org/wiki/English_language#Number_of_words_in_English&quot;&gt;are aware&lt;/a&gt; that the actual number of English words is much higher than the few hundred of thousand listed in the most thorough dictionaries. Moreover, dictionaries only list one word for each “version”, for example for verbs.&lt;/p&gt;

&lt;p&gt;Luckily, Google took a much finer snapshot of the &lt;strong&gt;living person&lt;/strong&gt; that is the English language, by recording &lt;a href=&quot;http://storage.googleapis.com/books/ngrams/books/datasetsv2.html&quot;&gt;all the words in many books from the sixteen century onwards&lt;/a&gt;. Google collected millions of books, with billions of pages and about one trillion of unique English word occurrences, in the setting they were actually used. There are downsides here too: mainly the mistakes by the OCR software converting the pictures to the text; also, this is still not accounting for all the words in the language: think about all the colloquial terms, the jargon, that people often use speaking with their friends or colleagues, but that will never be written down, and definitely not in a book!&lt;/p&gt;

&lt;h3 id=&quot;building-the-frequency-table&quot;&gt;Building the frequency table&lt;/h3&gt;

&lt;p&gt;So, let’s play with the Google corpus. The first thing to notice is that it is &lt;strong&gt;very large&lt;/strong&gt;. The list of words in American English starting with “a” takes about 1.5 GB uncompressed. But we are interested only in three letters words and in recent books (let’s say from 1980 onward) so we can download and filter these files at the same time with bash and a simple python script (sadly grep and python2 are easily confused with unicode characters):&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;x &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;a..z&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; other
&lt;span class=&quot;k&quot;&gt;do
  &lt;/span&gt;wget &lt;span class=&quot;nt&quot;&gt;-O&lt;/span&gt; - http://storage.googleapis.com/books/ngrams/books/googlebooks-eng-us-all-1gram-20120701-&lt;span class=&quot;nv&quot;&gt;$x&lt;/span&gt;.gz &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    | gunzip &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    | python3 filter.py &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; three_letters_words_en_us.txt
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;where filter.py is shown in &lt;a href=&quot;https://gist.github.com/stefano-maggiolo/f8ddab487ab7ba4bd204&quot;&gt;this GitHub gist&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The resulting file weights just 17 MB, much more manageable. Another short Python script (count.py in the same &lt;a href=&quot;https://gist.github.com/stefano-maggiolo/f8ddab487ab7ba4bd204&quot;&gt;gist&lt;/a&gt;) takes care of &lt;strong&gt;grouping the words and computing the frequency&lt;/strong&gt; (based on the total number of scanned words, that we extrapolated from the total_count file in the Google Ngram website).&lt;/p&gt;

&lt;h3 id=&quot;the-results&quot;&gt;The results&lt;/h3&gt;

&lt;p&gt;The resulting words for six languages are listed in the first sheet of &lt;a href=&quot;https://docs.google.com/spreadsheets/d/1Bb7a5kWRn6Po4eK20jOsF35R-0kBtpYMJJAusFLLLyk/pubhtml&quot;&gt;this Google Sheet&lt;/a&gt; in decreasing order. All frequency values are shown as &lt;strong&gt;base ten logarithms&lt;/strong&gt;, so a value of -1 means that that word (not differentiate between upper- or lowercase) was used once every ten words, -2 means every one hundred, and so on. The data is rearranged in the second sheet to show for each language how many words pass a certain frequency threshold, and in the third sheet there is a comparison with all possible trigrams.&lt;/p&gt;

&lt;p&gt;The first thing to notice is that this corpus is not perfect: due to &lt;strong&gt;misattributions and mixed language books&lt;/strong&gt;, you can find &lt;em&gt;the&lt;/em&gt; among the top Italian words, and several other errors.&lt;/p&gt;

&lt;p&gt;Also, due to mistakes in the recognition and to the size of the corpus, there are a lot of occasional “words” used only a handful of times. For this reason, I clipped the results to show only words that are more frequent than one in one million words (that is, that have a log probability greater than -6). Still, at the bottom there is a lot of garbage. The &lt;strong&gt;correct way to read the table&lt;/strong&gt; and the graphs is then to decide a minimum frequency, above which we consider those “words of the language”. By manual inspection, the values in which the transition happens is between -4.5 and -5.0.&lt;/p&gt;

&lt;h4 id=&quot;number-of-words&quot;&gt;Number of words&lt;/h4&gt;

&lt;figure class=&quot;right&quot; style=&quot;width: 250px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/words-above-freq.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_250_words-above-freq.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    Number of words above a certain frequency
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;To see which language has &lt;strong&gt;the most three-letter words&lt;/strong&gt;, we just need to see which line is highest around the 4.5-5.0 mark on the graph in the fourth sheet (that you can also see here on the right). The two lines for English (British and American), which are obviously very similar, are always well ahead of neolatin languages (Italian, Spanish and French) [&lt;sup id=&quot;fnref:4&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;]. German is ahead at the beginning, meaning that it has more very popular three-letter words, but loses its stamina as it progresses to rarer words, eventually aligning with neolatin languages.&lt;/p&gt;

&lt;h4 id=&quot;words-usage&quot;&gt;Words usage&lt;/h4&gt;

&lt;figure class=&quot;right&quot; style=&quot;width: 250px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/words-cumulative-usage.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_250_words-cumulative-usage.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    Cumulative usage of the top n words
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;Let us look now at words usage instead, that is, &lt;strong&gt;which proportion of words in actual books are three-letter words&lt;/strong&gt;. The answer is in the graph in the fifth sheet and again copied here on the left.&lt;/p&gt;

&lt;p&gt;Because of the strong start highlighted in the previous section, German leads: when you speak German, &lt;strong&gt;one in five word&lt;/strong&gt; has three letters! English is around the 15% mark, and neolatin languages are just around 10-11%. It is interesting that the proportion of the top five German three-letter words (&lt;em&gt;der&lt;/em&gt;, &lt;em&gt;die&lt;/em&gt;, &lt;em&gt;und&lt;/em&gt;, &lt;em&gt;von&lt;/em&gt;, &lt;em&gt;den&lt;/em&gt;) is more or less the same of the proportion of &lt;em&gt;all&lt;/em&gt; Italian three-letter words.&lt;/p&gt;

&lt;h4 id=&quot;the-original-question&quot;&gt;The original question&lt;/h4&gt;

&lt;p&gt;The question we started from was a different one, though: &lt;strong&gt;if it looks like a word, is it a word&lt;/strong&gt;? I collected some preliminary results on which percentage of trigrams are actual words in the considered languages in the third sheet (and in the last corresponding graph).&lt;/p&gt;

&lt;figure class=&quot;right&quot; style=&quot;width: 250px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/three-letter-words-over-trigrams.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_250_three-letter-words-over-trigrams.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    Percentage of three-letter words over all trigrams
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;The answer really depends on what we consider a letter: English is easy, 26 letters, but &lt;strong&gt;other languages are more complicated&lt;/strong&gt;. Italian as spoken and written nowadays, for example, has 21 “base” letters, and 7 additional letters with diacritics: &lt;em&gt;à&lt;/em&gt;, &lt;em&gt;è&lt;/em&gt;, &lt;em&gt;é&lt;/em&gt;, &lt;em&gt;ì&lt;/em&gt;, &lt;em&gt;ò&lt;/em&gt;, &lt;em&gt;ó&lt;/em&gt;, &lt;em&gt;ù&lt;/em&gt;: of these, only two have actual phonetic meaning (i.e., there is a phonetic difference between grave and acute accent), the others just mark the stressed syllable when it is the final one. Just a hundred year ago Italian had at least one base letter more (&lt;em&gt;j&lt;/em&gt;) and some more diacritics variation. So, how many trigrams are there in Italian, 21 to the third, or 28 to the third? I think that the correct answer is the first, but not really sure, so I left both versions in the sheet.&lt;/p&gt;

&lt;p&gt;Anyway, comparing the used words with all possible trigrams, it turns out that the language with the highest percentage of real words is… Italian! Not considering letter variants, Italian wins with 1.32%, over English with 0.9%. If we instead consider letter variants as different letters, then English wins with, no wonder, still 0.9% over Italian with 0.56%.&lt;/p&gt;

&lt;p&gt;This is really a rough approximation of the original question, as definitely not all trigrams look like words! As this post is already too long, I will try to answer to our original question, by counting how many trigrams look like a word, in a future post.&lt;/p&gt;

&lt;!-- DO NOT EDIT BELOW THIS LINE --&gt;
&lt;hr /&gt;

&lt;h3 id=&quot;part-of-this-series&quot;&gt;Part of this series&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;/if-it-looks-like-a-words-then-it-is-a-word/&quot;&gt;If it looks like a words, then it is a word (?)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/if-it-looks-like-a-word-it-is-a-word-one-third-of-the-time/&quot;&gt;If it looks like a word, it is a word one third of the time&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;footnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot;&gt;
      &lt;p&gt;I am not talking about accents here, these are different dialects. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot;&gt;
      &lt;p&gt;Admittedly, you will sound weird anyway, as you will invariably make mistakes in different directions and your sentence will be a mix of different dialects. &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot;&gt;
      &lt;p&gt;In particular because also the y axis is logarithmic, so at -4.5 Italian has only three-quarter of American English three-letter words, and Spanish just 60%. &lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Mon, 07 Jul 2014 00:00:00 +0000</pubDate>
        <link>http://blog.poormansmath.net/if-it-looks-like-a-words-then-it-is-a-word/</link>
        <guid isPermaLink="true">http://blog.poormansmath.net/if-it-looks-like-a-words-then-it-is-a-word/</guid>
      </item>
    
      <item>
        <title>Global time, emotional time, and the annoyance of DST</title>
        <description>&lt;p&gt;My post on the &lt;a href=&quot;/how-much-is-time-wrong-around-the-world/&quot;&gt;difference between local time and solar time&lt;/a&gt; obtained some mild popularity, and this gave me some time to think more about the subject of local vs. global time, and about emotional time. What is emotional time? Read on to know!&lt;/p&gt;

&lt;!--more--&gt;

&lt;figure class=&quot;right&quot; style=&quot;width: 250px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/SolarTimeVsStandardTime.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_250_SolarTimeVsStandardTime.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    Solar time vs standard time
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;One of the main reaction to my map was surprise about the &lt;strong&gt;predominance of red areas&lt;/strong&gt; (where the sun peaks after twelve o’clock) versus green areas (where the peak is before 12:00). This is easy to understand, if you think about it: would you prefer to live in a place where the sun shines from 05:00 to 17:00, or where it shines from 07:00 to 19:00? I doubt that many people would prefer the first (green) alternative to the second (red). [&lt;sup id=&quot;fnref:1&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;]&lt;/p&gt;

&lt;figure class=&quot;left&quot; style=&quot;width: 250px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/daylight-saving-world-subdivisions.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_250_daylight-saving-world-subdivisions.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    Areas observing DST
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;This explains why the majority of people is in a “red” part of the world, even &lt;strong&gt;without considering daylight saving time&lt;/strong&gt; [&lt;sup id=&quot;fnref:2&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;], that during the summer shifts most of Europe and Northern America one hour towards the red. [&lt;sup id=&quot;fnref:3&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;]&lt;/p&gt;

&lt;p&gt;Ok, so &lt;strong&gt;people prefer red places&lt;/strong&gt;, and even more in the summer. But the way people name a certain instant is really a convention, so why, instead of shifting everybody’s clocks, don’t we just let everyone chose the hour they wake up, open their shops, go to school and to sleep? Changing the hours of operation only for the businesses for which it makes sense would probably cause less problems than shifting hours for everybody, after all.&lt;/p&gt;

&lt;p&gt;The real problem with all of this is that people have a certain &lt;strong&gt;emotional “attachment”&lt;/strong&gt; to a specific time in the day: for most people, 06:00 is quite early, and they’d feel grumpy if they had to wake up at that hour. Dinner time is also deeply felt by most people, deriving from family habits: for most Italians, it is from 20:00 to 21:00, increasingly progressively going south. In England, it’s around 19:00. It is probably easier to change the underlying time than to convince people to modify their dinner habits to follow the sun.&lt;/p&gt;

&lt;p&gt;This is what I call &lt;strong&gt;emotional time&lt;/strong&gt;: the feeling, learned with experience and culture, that a specific hour is the best for a certain activity. What is the perfect time for dinner? Of course is 20:00, dinner time at my parents’ house when I grew up. What if one morning I wake up at 11? Well, certainly I was lazy. Emotional time has almost no connection with solar time: we eat at 20:00 all year round, even if that means we eat in the dark in December and before sunset in June.&lt;/p&gt;

&lt;h3 id=&quot;a-global-time&quot;&gt;A global time?&lt;/h3&gt;

&lt;p&gt;As distances around the globe become shorter thanks to the internet, the need for fixing &lt;strong&gt;appointment from different timezones&lt;/strong&gt; is increasing. If you correspond with just one or two other timezones, it is usually simple to remember one or two differences. [&lt;sup id=&quot;fnref:4&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;]&lt;/p&gt;

&lt;p&gt;Since emotional time varies only slightly around the world, it is then easy to understand which hours are reasonable for the other party. Just add the difference and compare with your emotional time, which hopefully is not very different from that in the other country.&lt;/p&gt;

&lt;figure class=&quot;left&quot; style=&quot;width: 150px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/swatch-beat-logo.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_150_swatch-beat-logo.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    Swatch Internet Time
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;Still, as the number of timezones to consider increases, this becomes more and more awkward, and there have been several attempts to create a &lt;strong&gt;global time&lt;/strong&gt;: a time system in which an instant is called in the same way anywhere in the world. In 1998, Swatch introduced the &lt;a href=&quot;http://www.swatch.com/gb_en/internettime/&quot;&gt;Swatch Internet Time&lt;/a&gt;, where a day is divided in 1000 &lt;em&gt;beats&lt;/em&gt;, each of them slightly shorted than 1.5 minutes. Swatch built upon the valid attempts of converting people to &lt;a href=&quot;http://en.wikipedia.org/wiki/Decimal_time&quot;&gt;decimal times&lt;/a&gt; during the French Revolution, but added the “global time” part. [&lt;sup id=&quot;fnref:5&quot;&gt;&lt;a href=&quot;#fn:5&quot; class=&quot;footnote&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;] &lt;a href=&quot;http://en.wikipedia.org/wiki/New_Earth_Time&quot;&gt;New Earth Time&lt;/a&gt; is a similar concepts of a global time, but based on angles instead of decimal systems, and hence every day is subdivided in 360 parts. &lt;a href=&quot;http://www.globetime.org/&quot;&gt;Globetime&lt;/a&gt; is a more recent project that has been brought to my attention, and uses the same subdivision.&lt;/p&gt;

&lt;p&gt;Of course, using &lt;strong&gt;UTC time&lt;/strong&gt; would be a similar way of using a unique time around the globe, but changing the unit (to decimal or sessagesimal) makes it easier to avoid confusion when switching between local and global time. But does a global time helps in arranging meetings? Yes and no: if you are arranging in person it might help to refer to a common global time that everyone has learned to tie to their local time; if instead you are proposing a meeting, than you need to learn the usual working hours of the other party, which is, if any, more difficult than remembering just the timezone difference and relying on the canonicity of emotional time. [&lt;sup id=&quot;fnref:6&quot;&gt;&lt;a href=&quot;#fn:6&quot; class=&quot;footnote&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;]&lt;/p&gt;

&lt;p&gt;Even more so, using a global time would mean that people had to lose their emotional connection with specific times, and the evidences show that this is hard for people, more than changing currency [&lt;sup id=&quot;fnref:7&quot;&gt;&lt;a href=&quot;#fn:7&quot; class=&quot;footnote&quot;&gt;7&lt;/a&gt;&lt;/sup&gt;], and probably harder than changing measurement system.&lt;/p&gt;

&lt;!-- DO NOT EDIT BELOW THIS LINE --&gt;
&lt;hr /&gt;

&lt;h3 id=&quot;see-also&quot;&gt;See also&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;/my-two-cents-on-the-daylight-saving-time/&quot;&gt;My two cents on the daylight saving time&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/how-much-is-time-wrong-around-the-world/&quot;&gt;How much is time wrong around the world?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/the-time-it-takes-to-change-the-time/&quot;&gt;The time it takes to change the time&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;footnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot;&gt;
      &lt;p&gt;Places like this exists: for the green one, an example is October in Recife, a city of almost four million people in eastern Brazil; for the red, May in Singapore. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot;&gt;
      &lt;p&gt;Several people asked for a version of the map considering DST. Sadly it would require a lot of time because of situations like this. &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot;&gt;
      &lt;p&gt;Russia is a notable exception because even though it technically does not observe DST, it recently switched time as to observe a permanent DST (and thus appears very red, inspiring a lot of communism jokes). Argentina looks similar, but their history is much more complicated. &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot;&gt;
      &lt;p&gt;Especially if the differences are of whole hours, and not of half-hours (like with India, Iran, and some parts of Australia), or of quarter-hours (like with Nepal). &lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:5&quot;&gt;
      &lt;p&gt;And, on the minus side, had the terrible idea of declaring its headquarters as the center of the new time system. &lt;a href=&quot;#fnref:5&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:6&quot;&gt;
      &lt;p&gt;A global time would really help during two weeks in the year, at least if you are organizing meetings between the UK and the US: their DST switch dates are not aligned, so for one week in March the time difference is just 7 hours instead than 8, and for one week in October it is 9 hours. If you have a recurring meeting, for those two weeks the time of the meeting would shift, but only for one side of the pond. &lt;a href=&quot;#fnref:6&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:7&quot;&gt;
      &lt;p&gt;Currencies, after all, change all the time thanks to inflation, so people are not locked in assigning an emotional value to specific quantities (or, they do, but then it is obvious that they are meaningless). &lt;a href=&quot;#fnref:7&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Mon, 02 Jun 2014 00:00:00 +0000</pubDate>
        <link>http://blog.poormansmath.net/emotional-time/</link>
        <guid isPermaLink="true">http://blog.poormansmath.net/emotional-time/</guid>
      </item>
    
      <item>
        <title>Suboptimal LaTeX #5: miscellanea</title>
        <description>&lt;p&gt;This post concludes the short series on LaTeX; we will see some other suggestion that did not fit in the other posts on &lt;a href=&quot;/suboptimal-latex-1-intro/&quot;&gt;generic mistakes and suggestions&lt;/a&gt;, &lt;a href=&quot;/suboptimal-latex-2-spacing/&quot;&gt;spacing&lt;/a&gt;, &lt;a href=&quot;/suboptimal-latex-3-mathematical-environments/&quot;&gt;math environments&lt;/a&gt; and &lt;a href=&quot;/suboptimal-latex-4-mathematics/&quot;&gt;mathematics&lt;/a&gt;.&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;The source with example from this post is in a &lt;a href=&quot;https://www.writelatex.com/read/nxycyqqcbyrd&quot;&gt;writeLaTeX&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;use-what-latex-gives-you-part-2&quot;&gt;Use what LaTeX gives you (part 2)&lt;/h3&gt;

&lt;p&gt;Even though the LaTeX-savyness of a person reading a post like this must be higher than normal, I’m still pretty sure that there is at least someone that does not know that there is no need to design a &lt;strong&gt;title page&lt;/strong&gt; by yourself: all decent classes handle the command &lt;code class=&quot;highlighter-rouge&quot;&gt;\maketitle&lt;/code&gt;, which takes the information from &lt;code class=&quot;highlighter-rouge&quot;&gt;\title&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;\author&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;\date&lt;/code&gt;. Oh, and for the last one, you can use &lt;code class=&quot;highlighter-rouge&quot;&gt;\today&lt;/code&gt;. Most classes also have an &lt;code class=&quot;highlighter-rouge&quot;&gt;\abstract&lt;/code&gt; macro.&lt;/p&gt;

&lt;p&gt;Another surprising hole in the LaTeX knowledge of some author is &lt;strong&gt;defining new macros&lt;/strong&gt; with &lt;code class=&quot;highlighter-rouge&quot;&gt;\newcommand&lt;/code&gt;: they are probably old TeX users, and therefore use &lt;code class=&quot;highlighter-rouge&quot;&gt;\def&lt;/code&gt;. The main advantage of &lt;code class=&quot;highlighter-rouge&quot;&gt;\newcommand&lt;/code&gt; is that it gives an error when the new macro’s name already exists, instead of silently overwriting it. Even if you do not use the existing macro, some other package might be relying on it, and weird errors may arise. If instead you are sure that there are no bad interactions, you can force the overwrite using &lt;code class=&quot;highlighter-rouge&quot;&gt;\renewcommand&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&quot;labels-and-refs&quot;&gt;Labels and refs&lt;/h3&gt;

&lt;figure class=&quot;right&quot; style=&quot;width: 150px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/miscellanea_eqref.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_150_miscellanea_eqref.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    (ref) and eqref
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;It might comes as a surprise, but I’ve also witnessed (fortunately, just two) authors not knowing about &lt;strong&gt;automatic references&lt;/strong&gt; with &lt;code class=&quot;highlighter-rouge&quot;&gt;\label&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;\ref&lt;/code&gt;. Fixing their articles has been… interesting. Much more common is not knowing about &lt;code class=&quot;highlighter-rouge&quot;&gt;\eqref&lt;/code&gt; for &lt;strong&gt;citing equations&lt;/strong&gt;: writing the parentheses by yourself achieve a similar looking result, but using a semantic command can be quite useful in the typesetting phase. Speaking of &lt;code class=&quot;highlighter-rouge&quot;&gt;\ref&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;\eqref&lt;/code&gt;, it is essential to use a &lt;strong&gt;non-breaking space&lt;/strong&gt; before them, to avoid having the number as the first character of a new line. To do so, just change the space with a tilde like in this example:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-latex&quot; data-lang=&quot;latex&quot;&gt;... as said in figure~&lt;span class=&quot;k&quot;&gt;\ref&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;fig:x&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;.&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Another frequent problem is to use the &lt;strong&gt;same label twice&lt;/strong&gt;: keep an eye for &lt;code class=&quot;highlighter-rouge&quot;&gt;LaTeX Warning: Label `x' multiply defined&lt;/code&gt; errors in the LaTeX logs. To mitigate the possibility of defining multiple labels, it is common to prepend the type to all labels names, for example &lt;code class=&quot;highlighter-rouge&quot;&gt;sec:cats&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;fig:cats&lt;/code&gt; for a section and a figure about cats, instead of just &lt;code class=&quot;highlighter-rouge&quot;&gt;cats&lt;/code&gt;… for both.&lt;/p&gt;

&lt;p&gt;Many authors also do not know that LaTeX is particularly tolerant with respect to a &lt;strong&gt;wrong position of the label&lt;/strong&gt; command! For example, a snippet like the following most probably does not do what the author wanted.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-latex&quot; data-lang=&quot;latex&quot;&gt;&lt;span class=&quot;nt&quot;&gt;\begin{figure}&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;\label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;cat&lt;span class=&quot;p&quot;&gt;_&lt;/span&gt;picture&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;\includegraphics&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;[width=\textwidth]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;cat&lt;span class=&quot;p&quot;&gt;_&lt;/span&gt;picture.jpg&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;\caption&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;This is a picture of a cat.&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;\end{figure}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Did you spot the problem? The numbering of the picture is given by the caption, not by the figure environment. Hence the label will not refer to the number of the figure, because it wasn’t defined yet! Instead, it will refer to the number of a previous element (like a section). You would assume that LaTeX gives you at least a warning for this suspect arrangement, but you’d be wrong. It is a good habit to write the label at the last possible time, even when not strictly necessary, in order to avoid these errors.&lt;/p&gt;

&lt;h3 id=&quot;theorem-environments&quot;&gt;Theorem environments&lt;/h3&gt;

&lt;p&gt;If you need to use &lt;strong&gt;theorems or similar environments&lt;/strong&gt;, the short story is to use the &lt;a href=&quot;ftp://ftp.ams.org/ams/doc/amscls/amsthdoc.pdf&quot;&gt;amsthm&lt;/a&gt; package. It allows you to define in one simple line the environment you need in your paper, for example:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-latex&quot; data-lang=&quot;latex&quot;&gt;&lt;span class=&quot;k&quot;&gt;\newtheorem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;thm&lt;span class=&quot;p&quot;&gt;}{&lt;/span&gt;Theorem&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;for a Theorem environment that you can use with &lt;code class=&quot;highlighter-rouge&quot;&gt;\begin{thm}&lt;/code&gt;. Remember that there are &lt;strong&gt;three predefined styles&lt;/strong&gt; of such environments, one well suited for statements to be proved (theorem, lemmas, etc.), one for definitions, examples, etc., and the last for additional notes and remarks. For example, this is a good preamble:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-latex&quot; data-lang=&quot;latex&quot;&gt;&lt;span class=&quot;k&quot;&gt;\theoremstyle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;plain&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;\newtheorem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;thm&lt;span class=&quot;p&quot;&gt;}{&lt;/span&gt;Theorem&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;\newtheorem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;lem&lt;span class=&quot;p&quot;&gt;}{&lt;/span&gt;Lemma&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;\theoremstyle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;definition&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;\newtheorem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;defn&lt;span class=&quot;p&quot;&gt;}{&lt;/span&gt;Definition&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;\newtheorem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;exmp&lt;span class=&quot;p&quot;&gt;}{&lt;/span&gt;Example&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;\theoremstyle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;remark&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;\newtheorem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;rem&lt;span class=&quot;p&quot;&gt;}{&lt;/span&gt;Remark&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;\newtheorem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;note&lt;span class=&quot;p&quot;&gt;}{&lt;/span&gt;Note&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;figure class=&quot;right&quot; style=&quot;width: 150px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/miscellanea_theorems.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_150_miscellanea_theorems.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    Theorems with amsthm
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;It also provides many other configurations, like whether to show the numbering and when to reset it.&lt;/p&gt;

&lt;p&gt;Finally, it has an embedded &lt;strong&gt;proof environment&lt;/strong&gt;, and a command &lt;code class=&quot;highlighter-rouge&quot;&gt;\qedhere&lt;/code&gt; to help LaTeX drawing the q.e.d. symbol at the correct place: indeed, if you finish your proof with a displayed equation, LaTeX by default places the symbol on the next line.&lt;/p&gt;

&lt;!-- DO NOT EDIT BELOW THIS LINE --&gt;
&lt;hr /&gt;

&lt;h3 id=&quot;part-of-this-series&quot;&gt;Part of this series&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;/suboptimal-latex-1-intro/&quot;&gt;Suboptimal LaTeX #1: intro&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/suboptimal-latex-2-spacing/&quot;&gt;Suboptimal LaTeX #2: spacing&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/suboptimal-latex-3-mathematical-environments/&quot;&gt;Suboptimal LaTeX #3: mathematical environments&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/suboptimal-latex-4-mathematics/&quot;&gt;Suboptimal LaTeX #4: mathematics&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/suboptimal-latex-5-miscellanea/&quot;&gt;Suboptimal LaTeX #5: miscellanea&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;see-also&quot;&gt;See also&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;/how-to-take-lecture-notes-with-latex/&quot;&gt;How to take lecture notes with LaTeX&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/latex-class-for-lecture-notes/&quot;&gt;LaTeX class for lecture notes&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
        <pubDate>Sun, 25 May 2014 00:00:00 +0000</pubDate>
        <link>http://blog.poormansmath.net/suboptimal-latex-5-miscellanea/</link>
        <guid isPermaLink="true">http://blog.poormansmath.net/suboptimal-latex-5-miscellanea/</guid>
      </item>
    
      <item>
        <title>Suboptimal LaTeX #4: mathematics</title>
        <description>&lt;p&gt;In the previous episodes: &lt;a href=&quot;/suboptimal-latex-1-intro/&quot;&gt;generic mistakes and suggestions&lt;/a&gt;, and how to fix the &lt;a href=&quot;/suboptimal-latex-2-spacing/&quot;&gt;spacing&lt;/a&gt; and &lt;a href=&quot;/suboptimal-latex-3-mathematical-environments/&quot;&gt;math environments&lt;/a&gt; in your papers. Continuing along these lines, in this post we will see some common mistakes done when writing mathematics.&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;As for the previous episodes, the source for all figures in this post is in a &lt;a href=&quot;https://www.writelatex.com/read/tpdkbvjtkgdr&quot;&gt;writeLaTeX&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;if-you-learn-one-thing-from-all-of-this-let-it-be-this&quot;&gt;If you learn one thing from all of this, let it be this&lt;/h3&gt;

&lt;p&gt;Every time I see a paper containing this mistake I cry a little bit: it is probably one of the most unprofessional errors that writers of scientific content with LaTeX can do. What is it? It is writing multi-letter symbols and even — please world forgive them — entire words in math mode without any escaping. It is simply horrible.&lt;/p&gt;

&lt;figure class=&quot;right&quot; style=&quot;width: 150px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/mathematics_text.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_150_mathematics_text.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    Text in math mode
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;What happens is that whenever you write letters as they are, LaTeX thinks that each letter is a symbol on its own. “&lt;code class=&quot;highlighter-rouge&quot;&gt;This is bad&lt;/code&gt;” in the figure is rendered as if each letter was a symbol and you were multiplying all of them together (of course, spaces disappear). I have seen this error in many situations, such as (from the less ugly to the ugliest):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;multi-letters symbols like the matrix spaces &lt;code class=&quot;highlighter-rouge&quot;&gt;SL&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;SO&lt;/code&gt;;&lt;/li&gt;
  &lt;li&gt;functions whose name is an abbreviation of a word, like &lt;code class=&quot;highlighter-rouge&quot;&gt;det&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;perm&lt;/code&gt;;&lt;/li&gt;
  &lt;li&gt;entire words;&lt;/li&gt;
  &lt;li&gt;or even sentences, like in &lt;code class=&quot;highlighter-rouge&quot;&gt;\{x \mid x is odd\}&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the case of multi-letters operators and functions (and, if you want, single-letter operators), you need to treat the letters as a single mathematical unit, with the spacing around them determined by their role. So for operators, you must use &lt;code class=&quot;highlighter-rouge&quot;&gt;\DeclareMathOperator&lt;/code&gt;; functions are a bit blurred: I use &lt;code class=&quot;highlighter-rouge&quot;&gt;\DeclareMathOperator&lt;/code&gt; too, but also &lt;code class=&quot;highlighter-rouge&quot;&gt;\mathrm&lt;/code&gt; is acceptable.&lt;/p&gt;

&lt;p&gt;In the other cases, you are inserting some text in mathematical mode; the correct way of doing that is using &lt;code class=&quot;highlighter-rouge&quot;&gt;\text&lt;/code&gt; (available in the &lt;code class=&quot;highlighter-rouge&quot;&gt;amsmath&lt;/code&gt; package), which instruct LaTeX to move temporarily back to text mode. Using &lt;code class=&quot;highlighter-rouge&quot;&gt;\mathrm&lt;/code&gt; is wrong because it just changes the shape of the letter, not their semantic (for example, spaces are ignored). Also, &lt;code class=&quot;highlighter-rouge&quot;&gt;\text&lt;/code&gt; draws the letters with the shape of the surrounding environment: if you are in a theorem, written in italic, then &lt;code class=&quot;highlighter-rouge&quot;&gt;\text&lt;/code&gt; will write in italic too. And finally, it respect font sizes if you use it, say, within an exponent.&lt;/p&gt;

&lt;h3 id=&quot;when-to-use-mathrm-and-the-myth-of-latex-taking-care-of-everything&quot;&gt;When to use &lt;code class=&quot;highlighter-rouge&quot;&gt;\mathrm&lt;/code&gt;, and the myth of LaTeX taking care of everything&lt;/h3&gt;

&lt;p&gt;Apart from the situation presented above (multi-letter function names), there is at least another important case where you should use &lt;code class=&quot;highlighter-rouge&quot;&gt;\mathrm&lt;/code&gt;: in the infamous “dx” at the end of an integral, the “d” should be upright… ok, maybe this is just my opinion, but it should!&lt;/p&gt;

&lt;figure class=&quot;right&quot; style=&quot;width: 150px&quot;&gt;
 &lt;div class=&quot;figure-container&quot;&gt;
  &lt;a href=&quot;/images/mathematics_dx.png&quot; class=&quot;imgpopup&quot;&gt;
   &lt;img src=&quot;/images/thumbnail_150_mathematics_dx.png&quot; /&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    Integrals and dx
  &lt;/figcaption&gt;
 &lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;Less debatable is the fact that LaTeX does not know that your “dx” has a different meaning in the integral than the function to integrate, and thus should be properly highlighted by leaving some space before it. I use the smallest standard space available, &lt;code class=&quot;highlighter-rouge&quot;&gt;\,&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;More in general, a lot of people support the myth that LaTeX knows better and typesets formulas in the best possible way. This is often true, with one big exception: when you, as a human, have more information about the formula than LaTeX. In that case, you should feel free to slightly tweak the formula. The most important thing to remember is to be consistent; in particular, it helps to use only the standard spacing macros (&lt;code class=&quot;highlighter-rouge&quot;&gt;\!&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;\,&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;\;&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;\quad&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;\qquad&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;The same applies to bracket sizing: leaving the decision to LaTeX, by using only &lt;code class=&quot;highlighter-rouge&quot;&gt;\left(&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;\right)&lt;/code&gt;, is certainly better than using only &lt;code class=&quot;highlighter-rouge&quot;&gt;(&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;)&lt;/code&gt;; but sometimes it is even better to decide for yourself. To do so, use &lt;code class=&quot;highlighter-rouge&quot;&gt;\&amp;lt;size&amp;gt;l(&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;\&amp;lt;size&amp;gt;r)&lt;/code&gt;, where size can be &lt;code class=&quot;highlighter-rouge&quot;&gt;big&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;Big&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;bigg&lt;/code&gt;, and &lt;code class=&quot;highlighter-rouge&quot;&gt;Bigg&lt;/code&gt; — and do not forget the &lt;code class=&quot;highlighter-rouge&quot;&gt;l&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;r&lt;/code&gt; to specify if you are opening or closing the bracket! The same is possible for all other parenthesis types, including &lt;code class=&quot;highlighter-rouge&quot;&gt;\langle&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;\rangle&lt;/code&gt;, that are almost always what you want instead of &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&quot;do-you-know-about-allowdisplaybreaks&quot;&gt;Do you know about &lt;code class=&quot;highlighter-rouge&quot;&gt;\allowdisplaybreaks&lt;/code&gt;?&lt;/h3&gt;

&lt;p&gt;Having a single equation going on for pages and pages is probably not the most compelling way of writing a paper… but sometimes it is necessary. By default, LaTeX does not break a page within a mathematical environment, so how do you avoid going over the page? Simple, you just break the environment in two!&lt;/p&gt;

&lt;p&gt;Simple and wrong, because then you have to change your equation if the text before it gets longer or shorter (but that would be fine if you do it in the &lt;a href=&quot;/suboptimal-latex-1-intro/&quot;&gt;typesetting phase&lt;/a&gt;), but also because the alignment gets lost. If all the lines in the first part are very long and all those in the second part are short, the second part will be more or less center aligned, instead of left aligned. And so the reader loses the visual cue hinting that all lines were part of a single group.&lt;/p&gt;

&lt;p&gt;The correct way is instead using &lt;code class=&quot;highlighter-rouge&quot;&gt;\allowdisplaybreaks&lt;/code&gt;, which does what it says: allows LaTeX to break pages within a mathematical environment. You can use it just after the &lt;code class=&quot;highlighter-rouge&quot;&gt;\begin{environment}&lt;/code&gt; to apply it only to that display. Moreover, if you end a line with &lt;code class=&quot;highlighter-rouge&quot;&gt;\\*&lt;/code&gt; instead of &lt;code class=&quot;highlighter-rouge&quot;&gt;\\&lt;/code&gt;, LaTeX won’t break after that line, which is very useful when you have a collection of equations with multiple lines.&lt;/p&gt;

&lt;h3 id=&quot;use-what-latex-gives-you&quot;&gt;Use what LaTeX gives you&lt;/h3&gt;

&lt;p&gt;A lot of people just use &lt;code class=&quot;highlighter-rouge&quot;&gt;...&lt;/code&gt; when &lt;code class=&quot;highlighter-rouge&quot;&gt;\dots&lt;/code&gt; is visually and semantically better. Most don’t know about &lt;code class=&quot;highlighter-rouge&quot;&gt;\cdots&lt;/code&gt; which is even better than &lt;code class=&quot;highlighter-rouge&quot;&gt;\dots&lt;/code&gt; within a chain of additions, for example. I have very rarely seen &lt;code class=&quot;highlighter-rouge&quot;&gt;\overbrace&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;\underbrace&lt;/code&gt; in the wild, and the same goes for &lt;code class=&quot;highlighter-rouge&quot;&gt;\xrightarrow&lt;/code&gt;, to draw arrows with text on top. Nobody uses the &lt;a href=&quot;http://www.ctan.org/pkg/cancel&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;cancel&lt;/code&gt;&lt;/a&gt; package to show that two terms were the opposite of each other. &lt;a href=&quot;http://www.ctan.org/pkg/xfrac&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;sfrac&lt;/code&gt;&lt;/a&gt; is almost unheard of, so instead of having beautiful diagonal fractions inside the text, we have either horrible &lt;code class=&quot;highlighter-rouge&quot;&gt;1/2&lt;/code&gt; or, even worse, huge gaps between lines.&lt;/p&gt;

&lt;p&gt;Even without resorting to obscure packages, that often causes problems when sending out your sources, LaTeX mathematics need not to be dull! You just need to know what &lt;a href=&quot;http://www.tex.ac.uk/tex-archive/info/symbols/comprehensive/symbols-a4.pdf&quot;&gt;symbols, accents, decorations&lt;/a&gt;, &lt;a href=&quot;/latex-class-for-lecture-notes/&quot;&gt;packages&lt;/a&gt; you can use.&lt;/p&gt;

&lt;!-- DO NOT EDIT BELOW THIS LINE --&gt;
&lt;hr /&gt;

&lt;h3 id=&quot;part-of-this-series&quot;&gt;Part of this series&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;/suboptimal-latex-1-intro/&quot;&gt;Suboptimal LaTeX #1: intro&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/suboptimal-latex-2-spacing/&quot;&gt;Suboptimal LaTeX #2: spacing&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/suboptimal-latex-3-mathematical-environments/&quot;&gt;Suboptimal LaTeX #3: mathematical environments&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/suboptimal-latex-4-mathematics/&quot;&gt;Suboptimal LaTeX #4: mathematics&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/suboptimal-latex-5-miscellanea/&quot;&gt;Suboptimal LaTeX #5: miscellanea&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;see-also&quot;&gt;See also&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;/how-to-take-lecture-notes-with-latex/&quot;&gt;How to take lecture notes with LaTeX&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/latex-class-for-lecture-notes/&quot;&gt;LaTeX class for lecture notes&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
        <pubDate>Mon, 10 Mar 2014 00:00:00 +0000</pubDate>
        <link>http://blog.poormansmath.net/suboptimal-latex-4-mathematics/</link>
        <guid isPermaLink="true">http://blog.poormansmath.net/suboptimal-latex-4-mathematics/</guid>
      </item>
    
  </channel>
</rss>