<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Cobra's bits (Posts about mathematics)</title><link>https://cobra.pdes-net.org</link><description></description><atom:link href="https://cobra.pdes-net.org/categories/mathematics.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2024 &lt;a href="mailto:najahannah@gmail.com"&gt;Cobra&lt;/a&gt; 
&lt;a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/"&gt;
&lt;img alt="Creative Commons License BY-NC-SA"
style="border-width:0; margin-bottom:12px;"
src="../images/by-nc-sa.svg"&gt;&lt;/a&gt;</copyright><lastBuildDate>Wed, 01 May 2024 12:19:59 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Units</title><link>https://cobra.pdes-net.org/posts/units.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;As a physicist, it is very useful to be able to perform calculations quickly, whether it is by pure mental arithmetic or on the back of an envelope. I'm immensely grateful for the training I've received in school that allows me to perform such calculations with relative ease. When I see my students struggling with even the most trivial of these calculations and having to rely on their smartphones to get a result, I get the impression that the education system is dismissing these skills as obsolete in our digital age. A big mistake, if you ask me.&lt;/p&gt;
&lt;p&gt;Don't get me wrong: when I need accurate results, I also resort to &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/rpn.html"&gt;calculators&lt;/a&gt; or calculator apps on &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/resistance-is-futile.html"&gt;Android&lt;/a&gt; or &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/calculators.html"&gt;Arch&lt;/a&gt;. And as an added benefit, some of them handle not only numbers, but also the units. This is really helpful, because converting numerical results from all sorts of obscure units to SI is often necessary when consulting older references, and it's as tedious as it is frustrating - just look at the &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Centimetre%E2%80%93gram%E2%80%93second_system_of_units"&gt;Wikipedia page of the cgs system&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Apart from Mathematica, I know of three command-line programs (one of which, namely, qalc, is also available with a graphical user interface) for doing calculations with units: the veteran &lt;a class="reference external" href="https://www.gnu.org/software/units/"&gt;units,&lt;/a&gt; the modern &lt;a class="reference external" href="https://qalculate.github.io/"&gt;qalc,&lt;/a&gt; and the new and hip &lt;a class="reference external" href="https://insect.sh/"&gt;insect.&lt;/a&gt; Here's an example of these three tools dealing with the conversion of the surface tension (in N/m) of water to surface energy (in eV/Å²), which for a liquid is one and the same despite the different units.&lt;/p&gt;
&lt;a class="reference external image-reference" href="https://cobra.pdes-net.org/images/units.webp"&gt;
&lt;img alt="../images/units.webp" class="align-center" src="https://cobra.pdes-net.org/images/units.webp" style="width: 600px;"&gt;
&lt;/a&gt;</description><category>linux</category><category>mathematics</category><guid>https://cobra.pdes-net.org/posts/units.html</guid><pubDate>Sun, 19 Jun 2022 12:17:54 GMT</pubDate></item><item><title>Functions with default values</title><link>https://cobra.pdes-net.org/posts/functions-with-default-values.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;Suppose you would like to have a command generating a secure password for an online service at the command line. You would google for that and find &lt;a class="reference external" href="http://www.howtogeek.com/howto/30184/10-ways-to-generate-a-random-password-from-the-command-line/"&gt;10 ways to generate a random password.&lt;/a&gt; At the end of his article, the author presents the ideal way to generate a secure password:&lt;/p&gt;
&lt;pre class="literal-block"&gt;date | md5sum&lt;/pre&gt;
&lt;p&gt;The author of the article (Lowell Heddings, the founder and CEO of How-To Geek) states:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I’m sure that some people will complain that it’s not as random as some of the other options, but honestly, it’s random enough if you’re going to be using the whole thing.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Random enough? Sure, the 'whole thing' looks random enough:&lt;/p&gt;
&lt;pre class="literal-block"&gt;9ec463af3db95e8e44de84417d9f408f&lt;/pre&gt;
&lt;p&gt;but the look is deceptive: this is in fact an extremely weak password. To understand why, let's look at the output of the 'date' command:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_950f188c3c8c4ea69de1f6e2c65f483f-1" name="rest_code_950f188c3c8c4ea69de1f6e2c65f483f-1" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_950f188c3c8c4ea69de1f6e2c65f483f-1"&gt;&lt;/a&gt;↪&lt;span class="w"&gt; &lt;/span&gt;date
&lt;a id="rest_code_950f188c3c8c4ea69de1f6e2c65f483f-2" name="rest_code_950f188c3c8c4ea69de1f6e2c65f483f-2" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_950f188c3c8c4ea69de1f6e2c65f483f-2"&gt;&lt;/a&gt;Sun&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;12&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;May&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2019&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;04&lt;/span&gt;:33:26&lt;span class="w"&gt; &lt;/span&gt;PM&lt;span class="w"&gt; &lt;/span&gt;CEST
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We see that without additional parameter (like +"%N"), 'date' gives us one password for each second of the year. How many passwords do we get in this way? Well,&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_7dfcd06833ab4f779d09395d4632245e-1" name="rest_code_7dfcd06833ab4f779d09395d4632245e-1" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_7dfcd06833ab4f779d09395d4632245e-1"&gt;&lt;/a&gt;&lt;span class="w"&gt; &lt;/span&gt;↪&lt;span class="w"&gt; &lt;/span&gt;date&lt;span class="w"&gt; &lt;/span&gt;+&lt;span class="s2"&gt;"%s"&lt;/span&gt;
&lt;a id="rest_code_7dfcd06833ab4f779d09395d4632245e-2" name="rest_code_7dfcd06833ab4f779d09395d4632245e-2" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_7dfcd06833ab4f779d09395d4632245e-2"&gt;&lt;/a&gt;&lt;span class="m"&gt;1557666649&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;i.e., 1,557,666,649 seconds has passed since 00:00:00, Jan 1, 1970 (&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Unix_time"&gt;Unix epoch time&lt;/a&gt;), and that's how many passwords we get.&lt;/p&gt;
&lt;p&gt;Now, the possibility to &lt;a class="reference external" href="https://en.wikipedia.org/wiki/List_of_websites_founded_before_1995"&gt;order Pizza online&lt;/a&gt; came much later, namely, at August 22nd, 1994.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_5a6769dc084248c693e55e32638fff21-1" name="rest_code_5a6769dc084248c693e55e32638fff21-1" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_5a6769dc084248c693e55e32638fff21-1"&gt;&lt;/a&gt;↪&lt;span class="w"&gt; &lt;/span&gt;date&lt;span class="w"&gt; &lt;/span&gt;-d&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;19940822&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;+&lt;span class="s2"&gt;"%s"&lt;/span&gt;
&lt;a id="rest_code_5a6769dc084248c693e55e32638fff21-2" name="rest_code_5a6769dc084248c693e55e32638fff21-2" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_5a6769dc084248c693e55e32638fff21-2"&gt;&lt;/a&gt;&lt;span class="m"&gt;777506400&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That leaves us with 780,160,249 passwords since this memorable day in 1994 or a complexity of 30 bits, corresponding to a 5-digit password with a character space of 62. Let's get one of these and see how difficult it is to crack:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_e89933a0486c400294d933a71dab42a9-1" name="rest_code_e89933a0486c400294d933a71dab42a9-1" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_e89933a0486c400294d933a71dab42a9-1"&gt;&lt;/a&gt;↪&lt;span class="w"&gt; &lt;/span&gt;pwgen&lt;span class="w"&gt; &lt;/span&gt;-s&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-1
&lt;a id="rest_code_e89933a0486c400294d933a71dab42a9-2" name="rest_code_e89933a0486c400294d933a71dab42a9-2" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_e89933a0486c400294d933a71dab42a9-2"&gt;&lt;/a&gt;p9iCN
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now, even my ancient GTX650Ti with its modest MD5 hashing performance of 1.5 GH/s cracks this password in 5 s (note that an RTX2080 delivers 36 GH/s...):&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-1" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-1" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-1"&gt;&lt;/a&gt;○&lt;span class="w"&gt; &lt;/span&gt;→&lt;span class="w"&gt; &lt;/span&gt;hashcat&lt;span class="w"&gt; &lt;/span&gt;-O&lt;span class="w"&gt; &lt;/span&gt;-a&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-m&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;myhashes.hash&lt;span class="w"&gt; &lt;/span&gt;?a?a?a?a?a
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-2" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-2" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-2"&gt;&lt;/a&gt;hashcat&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;v5.1.0&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;starting...
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-3" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-3" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-3"&gt;&lt;/a&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-4" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-4" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-4"&gt;&lt;/a&gt;OpenCL&lt;span class="w"&gt; &lt;/span&gt;Platform&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;#1: NVIDIA Corporation&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-5" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-5" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-5"&gt;&lt;/a&gt;&lt;span class="o"&gt;======================================&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-6" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-6" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-6"&gt;&lt;/a&gt;-&lt;span class="w"&gt; &lt;/span&gt;Device&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;#1: GeForce GTX 650 Ti, 243/972 MB allocatable, 4MCU&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-7" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-7" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-7"&gt;&lt;/a&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-8" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-8" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-8"&gt;&lt;/a&gt;0b91091d40a8623891367459d5b2a406:p9iCN
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-9" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-9" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-9"&gt;&lt;/a&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-10" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-10" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-10"&gt;&lt;/a&gt;Session..........:&lt;span class="w"&gt; &lt;/span&gt;hashcat
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-11" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-11" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-11"&gt;&lt;/a&gt;Status...........:&lt;span class="w"&gt; &lt;/span&gt;Cracked
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-12" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-12" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-12"&gt;&lt;/a&gt;Hash.Type........:&lt;span class="w"&gt; &lt;/span&gt;MD5
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-13" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-13" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-13"&gt;&lt;/a&gt;Hash.Target......:&lt;span class="w"&gt; &lt;/span&gt;0b91091d40a8623891367459d5b2a406
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-14" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-14" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-14"&gt;&lt;/a&gt;Time.Started.....:&lt;span class="w"&gt; &lt;/span&gt;Mon&lt;span class="w"&gt; &lt;/span&gt;May&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;13&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;12&lt;/span&gt;:48:58&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2019&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;secs&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-15" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-15" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-15"&gt;&lt;/a&gt;Time.Estimated...:&lt;span class="w"&gt; &lt;/span&gt;Mon&lt;span class="w"&gt; &lt;/span&gt;May&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;13&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;12&lt;/span&gt;:49:03&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2019&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;secs&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-16" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-16" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-16"&gt;&lt;/a&gt;Guess.Mask.......:&lt;span class="w"&gt; &lt;/span&gt;?a?a?a?a?a&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-17" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-17" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-17"&gt;&lt;/a&gt;Guess.Queue......:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;/1&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;100&lt;/span&gt;.00%&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-18" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-18" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-18"&gt;&lt;/a&gt;Speed.#1.........:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;514&lt;/span&gt;.0&lt;span class="w"&gt; &lt;/span&gt;MH/s&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;6&lt;/span&gt;.21ms&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;@&lt;span class="w"&gt; &lt;/span&gt;Accel:64&lt;span class="w"&gt; &lt;/span&gt;Loops:47&lt;span class="w"&gt; &lt;/span&gt;Thr:1024&lt;span class="w"&gt; &lt;/span&gt;Vec:2
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-19" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-19" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-19"&gt;&lt;/a&gt;Recovered........:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;/1&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;100&lt;/span&gt;.00%&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;Digests,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;/1&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;100&lt;/span&gt;.00%&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;Salts
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-20" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-20" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-20"&gt;&lt;/a&gt;Progress.........:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2328363008&lt;/span&gt;/7737809375&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;30&lt;/span&gt;.09%&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-21" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-21" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-21"&gt;&lt;/a&gt;Rejected.........:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;/2328363008&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;.00%&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-22" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-22" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-22"&gt;&lt;/a&gt;Restore.Point....:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;24379392&lt;/span&gt;/81450625&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;29&lt;/span&gt;.93%&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-23" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-23" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-23"&gt;&lt;/a&gt;Restore.Sub.#1...:&lt;span class="w"&gt; &lt;/span&gt;Salt:0&lt;span class="w"&gt; &lt;/span&gt;Amplifier:0-47&lt;span class="w"&gt; &lt;/span&gt;Iteration:0-47
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-24" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-24" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-24"&gt;&lt;/a&gt;Candidates.#1....:&lt;span class="w"&gt; &lt;/span&gt;s3v&lt;span class="se"&gt;\,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;RPuJG
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-25" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-25" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-25"&gt;&lt;/a&gt;Hardware.Mon.#1..:&lt;span class="w"&gt; &lt;/span&gt;Temp:&lt;span class="w"&gt; &lt;/span&gt;44c&lt;span class="w"&gt; &lt;/span&gt;Fan:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;33&lt;/span&gt;%
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;But actually, it's even worse: instead of cracking the hash one can easily precompute all possible values of the 'date | md5sum' command, and thus create a dictionary containing these “passwords”. I could start right away:&lt;/p&gt;
&lt;pre class="literal-block"&gt;for (( time=777506400; time&amp;lt;=1557666649; time++ )); do date -d@$time | md5sum | tr -d "-"; done &amp;gt; lowell_heddings_passwords.txt&lt;/pre&gt;
&lt;p&gt;On my desktop with its Xeon E3 v2, this command computes one million passwords in about half an hour, i.e, I'd need about 17 days for computing all passwords back to 1994. Writing a corresponding program running on the GPU would cut this down to seconds. Note that the resulting list of “random enough” passwords is static, i.e., it is indeed a dictionary, and not even a particularly large one.&lt;/p&gt;
&lt;p&gt;Lowell Heddings himself mentions several alternative ways to generate a password in &lt;a class="reference external" href="http://www.howtogeek.com/howto/30184/10-ways-to-generate-a-random-password-from-the-command-line/"&gt;his article&lt;/a&gt; before turning to the worst possible solution. But if we desire cryptographically secure solutions, even apparently innocuous commands are beset with difficulties, as pointed out by, for example, the &lt;a class="reference external" href="https://forums.freebsd.org/threads/44826/"&gt;carpetsmoker&lt;/a&gt; (better carpets than mattresses). In the end, it all boils down to the following three choices that are available on virtually any Linux installation. If we limit ourselves to a character space of 62:&lt;/p&gt;
&lt;pre class="literal-block"&gt;cat /dev/urandom | base64 | tr -d /=+ | head -c 25; echo
openssl rand -base64 25 | tr -d /=+ | head -c 25; echo
gpg2 --armor --gen-random 1 25 | tr -d /=+ | head -c 25; echo&lt;/pre&gt;
&lt;p&gt;If we insist of having almost all printable characters (which often calls for trouble):&lt;/p&gt;
&lt;pre class="literal-block"&gt;cat /dev/urandom | base91 | head -c 25
openssl rand 25 | base91 | head -c 25; echo
gpg2 --gen-random 1 25 | base91 | head -c 25; echo&lt;/pre&gt;
&lt;p&gt;One could, in principle, also utilize dedicated &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/password-generators.html"&gt;password generators&lt;/a&gt;, such as Theodore Tso's 'pwgen', Adel I. Mirzazhanov's 'apg', or haui's 'hpg':&lt;/p&gt;
&lt;pre class="literal-block"&gt;pwgen -s 25
apg -a 1 -M ncl -m 25 -x 25
hpg --alphanum 25&lt;/pre&gt;
&lt;p&gt;All of these ways are cryptographically equivalent in the sense that the entropy of the passwords generated by either of them asymptotically approaches the theoretical value ($\log_2(62) \approx 5.954$ bits per character) when you average over many (10,000,000 or more). In the present context (functions with default values) the generators do not offer any advantage, but only add unnecessary complexity.&lt;/p&gt;
&lt;p&gt;Now, whatever you chose as your favorite, you don't want to memorize the command or rely on the history of your favorite shell. One could define an alias with the password length as parameter, but I prefer to use a function for this case to have a default length of 25 characters with the option to change this value:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-1" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-1" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-1"&gt;&lt;/a&gt;↪&lt;span class="w"&gt; &lt;/span&gt;pw62
&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-2" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-2" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-2"&gt;&lt;/a&gt;mPcSU1c3lBTC7gChJ4MBw1sZW
&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-3" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-3" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-3"&gt;&lt;/a&gt;
&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-4" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-4" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-4"&gt;&lt;/a&gt;↪&lt;span class="w"&gt; &lt;/span&gt;pw62&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;8&lt;/span&gt;
&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-5" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-5" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-5"&gt;&lt;/a&gt;Yjs6NhYM
&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-6" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-6" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-6"&gt;&lt;/a&gt;
&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-7" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-7" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-7"&gt;&lt;/a&gt;↪&lt;span class="w"&gt; &lt;/span&gt;pw62&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;32&lt;/span&gt;
&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-8" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-8" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-8"&gt;&lt;/a&gt;cfn4KKugWHhOBF8qn6SO5Rj7uC2LksnK
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here's how to implement this functionality for the three major shells. Note the very elegant way with which a default value can be implemented within the bash. &lt;strong&gt;Update:&lt;/strong&gt; haui reminded me that the zsh is a drop-in replacement for the bash and thus of course implements all bash variable substitution, particularly ${var:-default}. Hence, we can use the same syntax for the bash and the zsh, and only the fish needs the comparatively clumsy construct shown below. 😎&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;bash&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="literal-block"&gt;function pw62
{
cat /dev/urandom | base64 | tr -d /=+ | head -c ${1:-25}; echo
}&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;fish&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="literal-block"&gt;function pw62
if set -q $argv
set length 25
else
set length $argv
end

cat /dev/urandom | base64 | tr -d /=+ | head -c $length; echo

end&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;zsh&lt;/strong&gt; (alternative to the bash syntax)&lt;/p&gt;
&lt;pre class="literal-block"&gt;function pw62()
{
if [ "$1" != "" ]
then
integer length=$1
else
integer length=25
fi

cat /dev/urandom | base64 | tr -d /=+ | head -c $length; echo
}&lt;/pre&gt;</description><category>encryption</category><category>linux</category><category>mathematics</category><guid>https://cobra.pdes-net.org/posts/functions-with-default-values.html</guid><pubDate>Sat, 25 May 2019 20:36:59 GMT</pubDate></item><item><title>Calculators</title><link>https://cobra.pdes-net.org/posts/calculators.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;For quick calculations, I prefer to use my &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/rpn.html"&gt;HP handheld calculators whenever possible&lt;/a&gt;, simply because I'm much faster with them than with anything else thanks their responsive physical keypad and, of course, RPN. Alas, there are computational tasks that few, if any, handhelds are up to. Big numbers, in particular, usually result in an overflow rather than in the desired solution. Let's take &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Factorial"&gt;factorials&lt;/a&gt; as example – they are &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Big_O_notation"&gt;faster growing&lt;/a&gt; than any ordinary functions (including exponential ones) and are thus perfectly suited for getting big numbers.&lt;/p&gt;
&lt;p&gt;Here's how the factorial &lt;span class="math"&gt;\(n!\)&lt;/span&gt; looks in comparison to its little sister, the exponential &lt;span class="math"&gt;\(e^n\)&lt;/span&gt;:&lt;/p&gt;
&lt;img alt="../images/factorial.svg" class="align-center" src="https://cobra.pdes-net.org/images/factorial.svg" style="width: 500px;"&gt;
&lt;p&gt;The dashed line shows the &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Stirling%27s_approximation"&gt;Stirling approximation&lt;/a&gt; &lt;span class="math"&gt;\(\sqrt{2 \pi n} \left(\frac{n}{e}\right)^n\)&lt;/span&gt;, which reveals that the factorial essentially grows with &lt;span class="math"&gt;\(n^n\)&lt;/span&gt; and thus faster than any exponential whatever its base.&lt;/p&gt;
&lt;p&gt;Now, the largest factorial my HP42s can handle is 253!, which amounts to 5.173460992e+499. For a handheld, this is more than respectable: the largest factorial one can compute on a Linux desktop with, for example, xcalc as the calculator application, is 170!, limited simply by the fact that numbers in xcalc are represented by &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Double-precision_floating-point_format"&gt;double precision floats&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;All right, xcalc is ancient. But as a matter of fact, most calculator applications running on Windows, MacOS, or Linux have &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/preferences.html"&gt;difficulties&lt;/a&gt; with large numbers. The Windows calculator, for example, gives up at any numbers bigger than 1e+10,000, and hence can't calculate factorials larger than 3249!. And we didn't even talk about getting &lt;em&gt;exact&lt;/em&gt; results, which demand &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic"&gt;arbitrary precision arithmetic&lt;/a&gt; already for much smaller numbers.&lt;/p&gt;
&lt;p&gt;Let's have a look at some calculators for Linux that can do better than those above. I use &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Wolfram_Mathematica"&gt;Mathematica 11.2&lt;/a&gt; as reference:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;1,000,000! = 8.263932e+5,565,708, taking 1.1/0.2 s for an exact result/numerical approximation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;100,000,000! = 1.617204e+756,570,556, taking 344/46 s for an exact result/numerical approximation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;0verflows at $MaxNumber 1.605216761933662e+1,355,718,576,299,609&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that a file storing the result of 100,000,000! has an uncompressed size of 0.757 GB. So be careful when writing even larger factorials to disk  😉 ($MaxNumber would be 1.35 PB!).&lt;/p&gt;
&lt;section id="cli-calculators"&gt;
&lt;h2&gt;CLI Calculators&lt;/h2&gt;
&lt;section id="bc-dc"&gt;
&lt;h3&gt;bc/dc&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;The&lt;/em&gt;  &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Dc_(computer_program)"&gt;Unix calculators&lt;/a&gt;. Offer arbitrary precision since 1970, and now you know what the 'bc' stands for in this blog's title!  😉 Neither of them supports factorials out of the box, but hey, these are programming languages, not plain calculators. Examples for scripts computing factorials can be found on &lt;a class="reference external" href="https://rosettacode.org/wiki/Factorial"&gt;Rosettacode&lt;/a&gt; and on &lt;a class="reference external" href="https://unix.stackexchange.com/questions/44226/bc-doesnt-support-log-and-factorial-calculation"&gt;Stackoverflow,&lt;/a&gt; but be aware that these examples are horribly inefficient — for fast algorithms see &lt;a class="reference external" href="http://www.luschny.de/math/factorial/FastFactorialFunctions.htm"&gt;Peter Luschny's page&lt;/a&gt;. Here's the “script” for dc:&lt;/p&gt;
&lt;pre class="literal-block"&gt;dc -e '?[q]sQ[d1=Qd1-lFx*]dsFxp'&lt;/pre&gt;
&lt;p&gt;After typing a number like 1000, we get an exact result. Overflows somewhat below 67,000!. bc does not, but it's too slow to be of much use for very much larger numbers.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="wcalc-1"&gt;
&lt;h3&gt;&lt;a class="reference external" href="http://w-calc.sourceforge.net/"&gt;wcalc&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Approximate results with principally arbitrary precision defined by the command line parameter P (which accepts only integers and is thus useless for really large numbers).&lt;/p&gt;
&lt;pre class="literal-block"&gt;wcalc -P 10 'fact(1000000)'&lt;/pre&gt;
&lt;p&gt;Takes 1.42 s, overflows somewhat below 44,500,000!&lt;/p&gt;
&lt;/section&gt;
&lt;section id="calc-1"&gt;
&lt;h3&gt;&lt;a class="reference external" href="https://github.com/lcn2/calc"&gt;calc&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;My default calculator on PCs. Gives exact results.&lt;/p&gt;
&lt;pre class="literal-block"&gt;calc 1000000!&lt;/pre&gt;
&lt;p&gt;Takes 330 s, and overflows somewhat below 2,200,000,000!&lt;/p&gt;
&lt;/section&gt;
&lt;section id="hypercalc-1"&gt;
&lt;h3&gt;&lt;a class="reference external" href="http://mrob.com/pub/perl/hypercalc.html"&gt;hypercalc&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When firing up hypercalc, we are greeted with ”Go ahead -- just TRY to make me overflow!”. And indeed, that's not an easy task at first. Hypercalc gives approximate results only, but essentially instantaneous ones even for absolutely monstrous numbers. The factorials we have considered so far are kids play for this program. Instead of the factorial of a million, a billion, a trillion, why not ask for the factorial of a &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Googol"&gt;Googol&lt;/a&gt;! Hypercalc tells us this number amounts to 1e+(9.9565705518098e+101), and that agrees with the solution from Wolfram Alpha (see below), the only tool, which can at least partly follow hypercalc into the realm of big numbers.&lt;/p&gt;
&lt;p&gt;But not when it comes to really big ones. Let's have a look, for example, at &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Factorial#Pickover%E2%80%99s_superfactorial"&gt;Pickover's superfactorial n$&lt;/a&gt;. What about, say, 10$? That's completely out of reach for any program I know, but not for hypercalc: 8pt8e+23804068 (PT stands for &lt;a class="reference external" href="http://mathworld.wolfram.com/PowerTower.html"&gt;PowerTower&lt;/a&gt;). But even this is still a very very very small number: hypercalc overflows only at 1e+308pt1e+34 or, equivalently in &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Knuth%27s_up-arrow_notation"&gt;Donald Knuth's up-arrow notation&lt;/a&gt;, 10↑↑1.7976e+308.&lt;/p&gt;
&lt;p&gt;All of this is contained in a Perl script available for &lt;a class="reference external" href="http://mrob.com/pub/comp/hypercalc/hypercalc.txt"&gt;download&lt;/a&gt; (or for installation in the &lt;a class="reference external" href="https://aur.archlinux.org/packages/hypercalc/"&gt;AUR&lt;/a&gt; for Archlinux users), and additionally in a &lt;a class="reference external" href="https://mrob.com/pub/comp/hypercalc/hypercalc-javascript.html"&gt;Javascript powered web interface&lt;/a&gt;.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="ipython"&gt;
&lt;h3&gt;iPython&lt;/h3&gt;
&lt;p&gt;So far, we haven't been able to get exact results faster than with Mathematica. Let's see how python is doing in this regard. There are two possibilities, the first using plain &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Python_(programming_language)"&gt;python&lt;/a&gt;, the second &lt;a class="reference external" href="https://en.wikipedia.org/wiki/SciPy"&gt;scipy&lt;/a&gt;:&lt;/p&gt;
&lt;pre class="literal-block"&gt;In [1]: import math
In [2]: %timeit math.factorial(1000000)
6.5 s ± 19.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [3]: from scipy.special import factorial
In [4]: %timeit factorial(1000000, exact=True)
6.53 s ± 17.9 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)&lt;/pre&gt;
&lt;p&gt;It's disappointing that scipy doesn't outperform regular python, but instead seems to use exactly the same code. A special function should, IMHO, perform better than Mathematica (which needs only 1 s for the same task).&lt;/p&gt;
&lt;p&gt;You can use python also directly from the terminal, and write the result to disk instead of displaying it directly:&lt;/p&gt;
&lt;pre class="literal-block"&gt;echo 1000000 | python -c 'import sys; import math; print(math.factorial(int(sys.stdin.readline())))' &amp;gt; fac1M.dat&lt;/pre&gt;
&lt;/section&gt;
&lt;section id="julia"&gt;
&lt;h3&gt;julia&lt;/h3&gt;
&lt;p&gt;Python turned out to be a disappointment, what about Julia, which is advertised to be suitable for &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Julia_(programming_language)"&gt;high-performance numerical analysis and computational science?&lt;/a&gt;&lt;/p&gt;
&lt;pre class="literal-block"&gt;julia&amp;gt; @time factorial(big(1000000));
0.162650 seconds (1.57 k allocations: 53.524 MiB, 2.00% gc time)
julia&amp;gt; @time factorial(big(100000000));
45.550577 seconds (432.60 k allocations: 11.586 GiB, 0.90% gc time)&lt;/pre&gt;
&lt;p&gt;Now we're talking!&lt;/p&gt;
&lt;p&gt;You can write the results to disk in this way:&lt;/p&gt;
&lt;pre class="literal-block"&gt;julia&amp;gt; using DelimitedFiles
julia&amp;gt; fac1M=factorial(big(1000000));
julia&amp;gt; writedlm("fac1M.dat", fac1M)&lt;/pre&gt;
&lt;/section&gt;
&lt;/section&gt;
&lt;section id="graphical-calculators"&gt;
&lt;h2&gt;Graphical calculators&lt;/h2&gt;
&lt;p&gt;Most desktop calculators still attempt to imitate the look of handhelds, just like media players used to resemble &lt;a class="reference external" href="https://s14-eu5.startpage.com/cgi-bin/serveimage?url=https:%2F%2Fimages-wixmp-ed30a86b8c4ca887773594c2.wixmp.com%2Ff%2F5713806b-d90c-440a-90f1-ff3b8fa05beb%2Fdarvsn2-5bb86d46-4fe8-42ee-907f-42a6de04d8f9.png%3Ftoken%3DeyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7InBhdGgiOiJcL2ZcLzU3MTM4MDZiLWQ5MGMtNDQwYS05MGYxLWZmM2I4ZmEwNWJlYlwvZGFydnNuMi01YmI4NmQ0Ni00ZmU4LTQyZWUtOTA3Zi00MmE2ZGUwNGQ4ZjkucG5nIn1dXSwiYXVkIjpbInVybjpzZXJ2aWNlOmZpbGUuZG93bmxvYWQiXX0.CtVxUj7_o5uxwd-3nxrr2LMT9HTaRkYMTNVkvdp_17Q&amp;amp;sp=7190fdacae16036b34859cdd7ce9f827"&gt;stereo decks&lt;/a&gt;. Some of these reconstructions are &lt;a class="reference external" href="https://thomasokken.com/free42/skins/desktop/HP-41.gif"&gt;historically accurate and appeal to our nostalgia&lt;/a&gt;, but in terms of usability, these relicts of the 1990s are among the most clumsy and inefficient user interfaces ever invented, particularly since people never use the keyboard to interact with these abominations, but the mouse. However, some graphical calculators give you the choice.&lt;/p&gt;
&lt;section id="qalculate-1"&gt;
&lt;h3&gt;&lt;a class="reference external" href="https://qalculate.github.io/"&gt;qalculate!&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A great general purpose calculator packed with features. Includes an RPN mode and a plotting interface to gnuplot, as well as excellent conversion utilities that can be updated daily (important for currencies).  We can get an approximate result for 1,000,000! in under 1 s, but 100,000,000! takes so long that I didn't wait. Overflows reportedly at 922,337,203,854,775,808!, which is impressive, but of little use because of the comparably poor performance.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="speedcrunch-1"&gt;
&lt;h3&gt;&lt;a class="reference external" href="https://speedcrunch.org/"&gt;speedcrunch&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Easy to use and insanely fast. Even on slow hardware, the result is there as soon as you type it. Overflows at 72,306,961!&lt;/p&gt;
&lt;/section&gt;
&lt;/section&gt;
&lt;section id="web-calculators"&gt;
&lt;h2&gt;Web calculators&lt;/h2&gt;
&lt;p&gt;Young people tell me that installing local apps is so 1990ish, and of course, you can perform essentially all calculations you ever need in the interwebs.&lt;/p&gt;
&lt;section id="casio"&gt;
&lt;h3&gt;Casio&lt;/h3&gt;
&lt;p&gt;When I look at my colleagues desks at the office, I frequently see Casio calculators from the 1980s. Even I have &lt;a class="reference external" href="https://upload.wikimedia.org/wikipedia/commons/c/c3/Casio_fx-10F_calculator.jpg"&gt;one&lt;/a&gt;, although I have no idea when and where I've acquired it (and I also don't remember ever using it). In any case, true to their roots, Casio offers a quite capable &lt;a class="reference external" href="https://keisan.casio.com/calculator"&gt;online calculator&lt;/a&gt;. It gives 1,000,000! in about 2 s and overflows only at 1e+100,000,000, just below 14,845,000!&lt;/p&gt;
&lt;/section&gt;
&lt;section id="wolfram-alpha"&gt;
&lt;h3&gt;Wolfram Alpha&lt;/h3&gt;
&lt;p&gt;More than a calculator: a knowledge engine. You may ask what's the &lt;a class="reference external" href="https://www.wolframalpha.com/input/?i=weather+in+berlin"&gt;weather in Berlin&lt;/a&gt; today, and get the interesting bit of information that on April 22nd, it was -4°C in 1997 and 31°C in 1968. But foremost, Wolfram Alpha is an &lt;a class="reference external" href="https://www.wolframalpha.com/examples/mathematics/numbers/arbitrary-precision/"&gt;arbitrary precision calculator.&lt;/a&gt; It gives exact results where appropriate (for reasonably sized outputs) and approximate ones when the output seems to large. Regardless the task, the answers take a few second, whether you calculate 2+2 or 1e+(9^9^9)! [1e+1e+(1.58274e+369693108)]. Overflows at (2e+1573347107)! or 1e+(1e+9.196824545990035)! That's much higher than Mathematica, but still nothing compared to hypercalc.&lt;/p&gt;
&lt;/section&gt;
&lt;/section&gt;</description><category>mathematics</category><guid>https://cobra.pdes-net.org/posts/calculators.html</guid><pubDate>Mon, 22 Apr 2019 16:03:35 GMT</pubDate></item><item><title>Representative surveys</title><link>https://cobra.pdes-net.org/posts/representative-surveys.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;Statistical surveys are a standard tool of sociology, and have been the subject of extensive research. In the hands of professionals, the results of these surveys can be surprisingly accurate. As a result, surveys have attained the status of the oracle of Delphi, and people fervently believe in them. Naturally, this development has made surveys an attractive tool for manipulating public opinion. The standard way to do this is to load the questions with a moral obligation. Don't you agree that &lt;a class="reference external" href="http://www.independent.co.uk/news/uk/politics/theresa-may-internet-regulated-london-bridge-terror-attack-google-facebook-whatsapp-borough-security-a7771896.html"&gt;the internet should be regulated to deprive extremists of their safe spaces online&lt;/a&gt;? No? Really, what a kind of person are you? Don't you ever think of the children?&lt;/p&gt;
&lt;p&gt;However, unexpected results of surveys do not always have sinister reasons, but may instead simply reflect the incompetence of the inquirer. In particular, the most elementary rule for designing a survey is frequently forgotten: namely, that those taking part in the survey have to understand the questions. Sounds obvious, doesn't it? But is it?&lt;/p&gt;
&lt;p&gt;An example: the recent news of heise online that only(!) 16% percent of all Germans encrypt their emails (&lt;a class="reference external" href="https://www.heise.de/newsticker/meldung/Umfrage-Nur-16-Prozent-der-Deutschen-verschluesseln-ihre-E-Mails-3720597.html"&gt;Umfrage: Nur 16 Prozent der Deutschen verschlüsseln ihre E-Mails&lt;/a&gt;). This survey was conducted by Convios Consulting on behalf of &lt;a class="reference external" href="https://de.wikipedia.org/wiki/United_Internet"&gt;United Internet&lt;/a&gt; (UI), one of the largest internet and mail providers in Germany.&lt;/p&gt;
&lt;p&gt;UI &lt;a class="reference external" href="https://newsroom.web.de/2017/05/22/der-trump-effekt-das-digitale-misstrauen-waechst/"&gt;claims&lt;/a&gt; that about 750,000 of their users have generated PGP key pairs. That's a very impressive number, particularly since according to UI, only 4.7 million keys “exist” worldwide. The UI users would thus account for 16% of all PGP keys. Doesn't that demonstrate very nicely that UI's &lt;a class="reference external" href="https://www.theregister.co.uk/2016/10/06/pgp_email_service_gmx/"&gt;encryption initiative&lt;/a&gt; introduced in August 2016 is highly successful?&lt;/p&gt;
&lt;p&gt;Well, the whole reason for the survey was to create exactly this impression. I have no doubts that the numbers quoted above are correct, but what do they mean?&lt;/p&gt;
&lt;p&gt;First of all, the number reported for the existing keys worldwide only accounts for the keys that have been deposited on &lt;a class="reference external" href="https://sks-keyservers.net/status/key_development.php"&gt;key servers.&lt;/a&gt; Nobody can estimate how many keys have actually been generated or are in use. That's quite different in the case of the UI encryption scheme, which is based on &lt;a class="reference external" href="http://pdes-net.org/cobra/posts/encryption-for-humans.html"&gt;mailvelope,&lt;/a&gt; and the &lt;a class="reference external" href="https://www.heise.de/newsticker/meldung/Web-de-und-GMX-fuehren-PGP-Verschluesselung-fuer-Mail-ein-2786133.html"&gt;storage of the public key of the user in a database located on a UI server&lt;/a&gt;. The number given above is thus the total number of UI customers with a PGP key, unless they use a separate key in a stand-alone MUA (of which I know two 😉).&lt;/p&gt;
&lt;p&gt;There are about &lt;a class="reference external" href="https://de.statista.com/themen/2249/e-mail-nutzung/"&gt;40 million&lt;/a&gt; email users in Germany. According to UI, about &lt;a class="reference external" href="https://newsroom.web.de/2017/05/22/der-trump-effekt-das-digitale-misstrauen-waechst/"&gt;half&lt;/a&gt; of them use GMX or WEB.DE, which seems reasonable as UI is reported to have close to &lt;a class="reference external" href="http://www.handelsblatt.com/unternehmen/it-medien/1und1-gmx-web-de-united-internet-peilt-die-marke-von-20-millionen-kunden-an/19561364.html"&gt;20 million&lt;/a&gt; customers. Now, let's suppose that all UI customers who have generated a key are also actually using it to encrypt their mail. In this unlikely case, 3.75% of all UI users would encrypt their mail, much less than the “only 16%” of their survey. Obviously, that must mean that 28.25% of the other 20 million email users in Germany, who are mostly customers of the German Telekom, Google, and Microsoft, encrypt their mail. Right?&lt;/p&gt;
&lt;p&gt;Of course not. Try to ask arbitrary Gmail users if they encrypt their mail. 84% will look at you with with blank eyes, but 16% will &lt;a class="reference external" href="https://blog.google/products/gmail/making-email-safer-for-you-posted-by/"&gt;recognize&lt;/a&gt; the word and confirm that they do, YES! Ask them afterwards if they know the difference between transport and end-to-end encryption. I guarantee that you will soon get tired of asking people because even after several hundreds you won't find a single one who can answer your second question...&lt;/p&gt;
&lt;p&gt;How many people do encrypt their mails? I don't think there exist any bona fide surveys on that topic. I can only provide anecdotal evidence with very limited statistical significance. On the other hand, I've been a serious advocate of end-to-end-encryption since about 15 years. I've written tutorials and motivated many of my personal contacts to use end-to-end encryption in email and messenging. Well, some would say I forced them at gunpoint. But that would be exaggerated...&lt;/p&gt;
&lt;p&gt;I have currently 49 personal contacts with public PGP keys, and 16 business contacts. That doesn't sound too bad, does it? However, 17 and 4 of these keys are expired, leaving 32 and 12, respectively. Subtracting keys whose pass phrases have been forgotten by their users or were otherwise disposed of leaves 19 and 7. Some of my contacts have passed away, are retired, or I've simply lost touch, leaving in the end 4 and 5 with which I can, in principle, exchange end-to-end encrypted mails. Actually, however, there are only three persons with whom I regularly exchange encrypted mails: my patent attorney at work and my fellow PdeS (that's why they have that label) in actual life.&lt;/p&gt;
&lt;p&gt;Three out of 65 with an actively used key, but of how many without any clue what that even means? I don't want to spent time on the question of how I could count the number of unique addresses in my mail folders over the past few years. But obviously, this number would be in the several hundreds. In other words, the total percentage of people employing end-to end-encryption in &lt;em&gt;my&lt;/em&gt; emails is way lower than 1%. And if I wouldn't be interested in these kind of things, and if I wouldn't be a scientist, this percentage would be exactly zero. Not 16%. Not 0.16%. Zero.&lt;/p&gt;
&lt;p&gt;Can we find out how many people really encrypt their mails by a survey? Not really. If less than 100 ppm of all people encrypt (which is the number I find most plausible), we would need a mega-survey over 50000 people to include at least 5 people who actually do encrypt, and that's never going to happen. And don't let them tell you that the rules of statistics somehow don't apply there and representative surveys can answer all of these questions as if by magic. &lt;a class="reference external" href="https://www.youtube.com/watch?v=c4psKYpfnYs"&gt;That's bullshit. All of it.&lt;/a&gt;&lt;/p&gt;</description><category>encryption</category><category>info</category><category>mathematics</category><category>thoughts</category><guid>https://cobra.pdes-net.org/posts/representative-surveys.html</guid><pubDate>Sun, 25 Jun 2017 14:34:20 GMT</pubDate></item><item><title>Indices</title><link>https://cobra.pdes-net.org/posts/indices.html</link><dc:creator>Cobra</dc:creator><description>&lt;h3&gt;&lt;a href="http://pdes-net.org/scripts/indices.tar.xz"&gt;A ȷupyter notebook&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Scientists move in mysterious ways, particularly when they try to measure their individual performance as a scientist. As I've explained in a &lt;a href="http://pdes-net.org/cobra/posts/rsums-and-indices.html"&gt;previous post&lt;/a&gt;, the most popular and commonly accepted of these measures is the &lt;a href="http://en.wikipedia.org/wiki/H-index"&gt;h index&lt;/a&gt; $\mathcal{H}$, which has been declared to be superfluous on both &lt;a href="http://michaelnielsen.org/blog/why-the-h-index-is-virtually-no-use/"&gt;empirical&lt;/a&gt; and &lt;a href="http://www.ams.org/journals/notices/201409/rnoti-p1040.pdf"&gt;mathematical&lt;/a&gt; grounds. Either of these references relates $\mathcal{H}$ to the square root of the total number of citations $\mathcal{N}$, the first one approximately &lt;/p&gt;
&lt;p&gt;$\mathcal{H} \approx 0.5 \sqrt{\mathcal{N}}$&lt;/p&gt;
&lt;p&gt;and the second one exactly:&lt;/p&gt;
&lt;p&gt;$\mathcal{H}=\sqrt{6}\log{2}\sqrt{\mathcal{N}}/\pi \approx 0.54 \sqrt{\mathcal{N}} $.&lt;/p&gt;
&lt;p&gt;Since I anyway wanted to test &lt;a href="http://pandas.pydata.org/"&gt;pandas&lt;/a&gt;, &lt;a href="https://stanford.edu/~mwaskom/software/seaborn/"&gt;seaborn&lt;/a&gt; and &lt;a href="http://statsmodels.sourceforge.net/"&gt;statsmodel&lt;/a&gt;, I gathered $\mathcal{H}$, $\mathcal{N}$, and the i10 index $\mathcal{I}$ from all my coauthors on Google Scholar. It turned out that not even a quarter of my coauthors have a Google Scholar account, but I figured that 71 data points would provide an acceptable statistics. &lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;matplotlib&lt;/span&gt; &lt;span class="n"&gt;inline&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;np&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;matplotlib&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;mpl&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;plt&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;statsmodels.formula.api&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;sm&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;seaborn&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;sns&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="c1"&gt;# read data into a Pandas DataFrame&lt;/span&gt;
&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read_table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/home/cobra/ownCloud/MyStuff/projects/python/publishing/hindex.dat"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# check the data head&lt;/span&gt;
&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;div&gt;
&lt;table border="1" class="dataframe"&gt;
  &lt;thead&gt;
    &lt;tr style="text-align: right;"&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;Citations&lt;/th&gt;
      &lt;th&gt;Hindex&lt;/th&gt;
      &lt;th&gt;i10index&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;0&lt;/th&gt;
      &lt;td&gt;952&lt;/td&gt;
      &lt;td&gt;12&lt;/td&gt;
      &lt;td&gt;17&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;1&lt;/th&gt;
      &lt;td&gt;1913&lt;/td&gt;
      &lt;td&gt;20&lt;/td&gt;
      &lt;td&gt;35&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;2&lt;/th&gt;
      &lt;td&gt;5327&lt;/td&gt;
      &lt;td&gt;34&lt;/td&gt;
      &lt;td&gt;151&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;3&lt;/th&gt;
      &lt;td&gt;650&lt;/td&gt;
      &lt;td&gt;13&lt;/td&gt;
      &lt;td&gt;14&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;4&lt;/th&gt;
      &lt;td&gt;3855&lt;/td&gt;
      &lt;td&gt;25&lt;/td&gt;
      &lt;td&gt;68&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;Looks all right.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;logdata&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log10&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The correlation of the data is much more clear when displayed logarithmically:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="nb"&gt;vars&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Citations"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Hindex"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"i10index"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pairplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;logdata&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;vars&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;vars&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"reg"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="png" src="https://cobra.pdes-net.org/images/corrmatrix.png"&gt;&lt;/p&gt;
&lt;p&gt;Now look at &lt;em&gt;that!&lt;/em&gt; Two lines of code and seaborn visualizes all correlations in my data set. The diagonal elements of this 3x3 matrix plot show the distributions of $\mathcal{N}$, $\mathcal{H}$, and $\mathcal{I}$ (which seem to be close to normal distributions), and the off-diagonal elements visualize their correlations emphasized by a linear regression (kind="reg"). And how correlated they are! There's indeed no need for a definition of 'indices' if the number of citations is all what it boils down to.&lt;/p&gt;
&lt;p&gt;Seaborn is great for visualization, as we have seen, but for quantitative statistical information, it's better to use statsmodel:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;hc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ols&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;formula&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'Hindex ~ Citations'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;logdata&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;fithc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;ic&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ols&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;formula&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'i10index ~ Citations'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;logdata&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;fitic&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ic&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ols&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;formula&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'Hindex ~ i10index'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;logdata&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;fithi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Let's compare the slope of our data with that predicted above:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;fithc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Citations&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="mf"&gt;0.45708354021378172&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pi&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="mf"&gt;0.54044463946673071&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Solid state phycisists have to work harder!&lt;/p&gt;
&lt;p&gt;One can get also get more information, if desired:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;fithi&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;style type="text/css"&gt;
&lt;!--
TD{font-family: Monospace; font-size: 10pt;}
TH{font-family: Monospace; font-size: 10pt;}
---&gt;
&lt;/style&gt;

&lt;table style="text-align: left; class=" simpletable&gt;
&lt;caption&gt;OLS Regression Results&lt;/caption&gt;
&lt;tr&gt;
  &lt;th&gt;Dep. Variable:&lt;/th&gt;         &lt;td&gt;Hindex&lt;/td&gt;      &lt;th&gt;  R-squared:         &lt;/th&gt; &lt;td&gt;   0.974&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Model:&lt;/th&gt;                   &lt;td&gt;OLS&lt;/td&gt;       &lt;th&gt;  Adj. R-squared:    &lt;/th&gt; &lt;td&gt;   0.974&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Method:&lt;/th&gt;             &lt;td&gt;Least Squares&lt;/td&gt;  &lt;th&gt;  F-statistic:       &lt;/th&gt; &lt;td&gt;   2592.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Date:&lt;/th&gt;             &lt;td&gt;Mon, 16 May 2016&lt;/td&gt; &lt;th&gt;  Prob (F-statistic):&lt;/th&gt; &lt;td&gt;1.84e-56&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Time:&lt;/th&gt;                 &lt;td&gt;14:42:47&lt;/td&gt;     &lt;th&gt;  Log-Likelihood:    &lt;/th&gt; &lt;td&gt;  114.08&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;No. Observations:&lt;/th&gt;      &lt;td&gt;    71&lt;/td&gt;      &lt;th&gt;  AIC:               &lt;/th&gt; &lt;td&gt;  -224.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Df Residuals:&lt;/th&gt;          &lt;td&gt;    69&lt;/td&gt;      &lt;th&gt;  BIC:               &lt;/th&gt; &lt;td&gt;  -219.6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Df Model:&lt;/th&gt;              &lt;td&gt;     1&lt;/td&gt;      &lt;th&gt;                     &lt;/th&gt;     &lt;td&gt; &lt;/td&gt;   
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Covariance Type:&lt;/th&gt;      &lt;td&gt;nonrobust&lt;/td&gt;    &lt;th&gt;                     &lt;/th&gt;     &lt;td&gt; &lt;/td&gt;   
&lt;/tr&gt;
&lt;/table&gt;
&lt;table style="text-align: left; class=" simpletable&gt;
&lt;tr&gt;
      &lt;td&gt;&lt;/td&gt;         &lt;th&gt;coef&lt;/th&gt;     &lt;th&gt;std err&lt;/th&gt;      &lt;th&gt;t&lt;/th&gt;      &lt;th&gt;P&amp;gt;|t|&lt;/th&gt; &lt;th&gt;[95.0% Conf. Int.]&lt;/th&gt; 
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Intercept&lt;/th&gt; &lt;td&gt;    0.4498&lt;/td&gt; &lt;td&gt;    0.019&lt;/td&gt; &lt;td&gt;   23.723&lt;/td&gt; &lt;td&gt; 0.000&lt;/td&gt; &lt;td&gt;    0.412     0.488&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;i10index&lt;/th&gt;  &lt;td&gt;    0.5454&lt;/td&gt; &lt;td&gt;    0.011&lt;/td&gt; &lt;td&gt;   50.910&lt;/td&gt; &lt;td&gt; 0.000&lt;/td&gt; &lt;td&gt;    0.524     0.567&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;table style="text-align: left; class=" simpletable&gt;
&lt;tr&gt;
  &lt;th&gt;Omnibus:&lt;/th&gt;       &lt;td&gt; 3.438&lt;/td&gt; &lt;th&gt;  Durbin-Watson:     &lt;/th&gt; &lt;td&gt;   2.391&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Prob(Omnibus):&lt;/th&gt; &lt;td&gt; 0.179&lt;/td&gt; &lt;th&gt;  Jarque-Bera (JB):  &lt;/th&gt; &lt;td&gt;   2.600&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Skew:&lt;/th&gt;          &lt;td&gt;-0.408&lt;/td&gt; &lt;th&gt;  Prob(JB):          &lt;/th&gt; &lt;td&gt;   0.273&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Kurtosis:&lt;/th&gt;      &lt;td&gt; 3.462&lt;/td&gt; &lt;th&gt;  Cond. No.          &lt;/th&gt; &lt;td&gt;    7.44&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;And of course, we can display these fits independent of seaborn:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;xlist_cit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s1"&gt;'Citations'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;logdata&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Citations&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;logdata&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Citations&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;()]})&lt;/span&gt;
&lt;span class="n"&gt;xlist_i10&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s1"&gt;'i10index'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;logdata&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;i10index&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;logdata&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;i10index&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;()]})&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;preds_hcit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fithc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xlist_cit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;preds_hcit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;preds_i10cit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fitic&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xlist_cit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;preds_i10cit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;preds_hi10&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fithi&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xlist_i10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;preds_hi10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;logdata&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'scatter'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'Citations'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'Hindex'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xlist_cit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;preds_hcit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'red'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;linewidth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;logdata&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'scatter'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'Citations'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'i10index'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xlist_cit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;preds_i10cit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'red'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;linewidth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;logdata&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'scatter'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'i10index'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'Hindex'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xlist_i10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;preds_hi10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'red'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;linewidth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="png" src="https://cobra.pdes-net.org/images/corr1.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="png" src="https://cobra.pdes-net.org/images/corr2.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="png" src="https://cobra.pdes-net.org/images/corr3.png"&gt;&lt;/p&gt;</description><category>mathematics</category><category>presentations</category><guid>https://cobra.pdes-net.org/posts/indices.html</guid><pubDate>Sun, 22 May 2016 09:03:48 GMT</pubDate></item><item><title>Image quality</title><link>https://cobra.pdes-net.org/posts/image-quality.html</link><dc:creator>Cobra</dc:creator><description>&lt;h3&gt;&lt;a href="http://pdes-net.org/scripts/ssim.tar.xz"&gt;A ȷupyter notebook&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If I would be asked to nominate the one property which characterizes the modern world best, it would be its increasing focus on graphical representations. We are experiencing a transition from a textual to a pictorial society. People communicate with each other not by sending texts, but by photographs on social networks or emojis in chat applications. They learn how to do that not by reading a manual, but by video tutorials. Even highly technical articles on IT oriented websites are invariably illustrated, however &lt;a href="http://www.heise.de/newsticker/meldung/JavaScript-npm-aendert-Unpublish-Policy-fuer-Pakete-3155904.html"&gt;unrelated&lt;/a&gt; or &lt;a href="http://www.heise.de/newsticker/meldung/Versionskontrolle-Git-2-8-beschleunigt-durch-Parallelisierung-3152154.html"&gt;absurd&lt;/a&gt; the respective illustration may be.&lt;/p&gt;
&lt;p&gt;I have no serious problem with that as long as the images are a pleasure to look at and are nice to my band width. For keeping this balance, however, a certain understanding of graphic formats is helpful. Only yesterday I received a two-page abstract for a conference which weighed a hefty 73 MB. Saving the images in an appropriate format reduced the size to 1.2 MB. That was not even the &lt;a href="http://pdes-net.org/cobra/posts/squandering.html"&gt;most extreme example&lt;/a&gt; I've experienced with excessively large files...&lt;/p&gt;
&lt;p&gt;More frequently, however, the problem is not an excessive image size but a mediocre image quality. To avoid this problem requires either a certain &lt;a href="http://pdes-net.org/cobra/posts/image-size.html"&gt;perceptiveness&lt;/a&gt;, or an algorithm suitable for an objective ranking of image quality. The &lt;a href="https://en.wikipedia.org/wiki/Structural_similarity"&gt;structural similarity index&lt;/a&gt; (SSIM) is such an algorithm, and is widely used as video quality metrics in the televison industry. &lt;/p&gt;
&lt;p&gt;The present ȷupyter notebook calculates the SSIM for two bitmaps derived from a vector graphics. The first bitmap is obtained by&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;pdftocairo -png -r 1200 org.pdf org.png
pngquant org.png web.png
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The resulting bitmaps measure 550×934 px, and the files 'org.png' and 'web.png' are 30519 and 14797 bytes in size, respectively — significantly larger than the original graphics 'org.pdf' (4214 bytes).  &lt;/p&gt;
&lt;p&gt;Can we reduce this size further by converting the image to the &lt;a href="http://pdes-net.org/cobra/posts/generation-jpeg.html"&gt;popular jpeg format&lt;/a&gt;? As was to be expected for a line graphics with hard contrasts, we can, but pay the prize of a much reduced image quality. Indeed, to obtain a jpeg file of similar size (to be precise, 15556 bytes) we have to use very low settings:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;convert org.png -quality 20 lossy.jpg
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;As you see in the comparison below, the SSIM for 'web.png' is almost identical to the original, while that of 'lossy.jpg' is drastically lower. And many of you will probably wonder why, since you don't see a difference in the images below – right? &lt;/p&gt;
&lt;p&gt;I do, but I have a trained eye. To convince you that the SSIM is meaningful, here are the two images for direct inspection: &lt;a href="https://cobra.pdes-net.org/images/web.png"&gt;web.png&lt;/a&gt; &lt;a href="https://cobra.pdes-net.org/images/lossy.jpg"&gt;lossy.jpg&lt;/a&gt;.  &lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;matplotlib&lt;/span&gt; &lt;span class="n"&gt;inline&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;np&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;matplotlib&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;mpl&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;plt&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;skimage&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;img_as_float&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;skimage.io&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;io&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;skimage.measure&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;compare_ssim&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;ssim&lt;/span&gt;

&lt;span class="n"&gt;mpl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rcParams&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'font.size'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;
&lt;span class="n"&gt;mpl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rcParams&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'figure.figsize'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;org&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'org.png'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;as_grey&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;org_png&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'web.png'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;as_grey&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;org_jpg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'lossy.jpg'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;as_grey&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;img_org&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;img_as_float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;img_png&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;img_as_float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;org_png&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;img_jpg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;img_as_float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;org_jpg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;fig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ax0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nrows&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ncols&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tight_layout&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;ssim_none&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ssim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img_org&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;img_org&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;multichannel&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                 &lt;span class="n"&gt;dynamic_range&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;img_org&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;img_org&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="n"&gt;ssim_png&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ssim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img_org&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;img_png&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;multichannel&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                  &lt;span class="n"&gt;dynamic_range&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;img_png&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;img_png&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="n"&gt;ssim_jpg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ssim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img_org&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;img_jpg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;multichannel&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                  &lt;span class="n"&gt;dynamic_range&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;img_jpg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;img_jpg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'SSIM: &lt;/span&gt;&lt;span class="si"&gt;%.4f&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;

&lt;span class="n"&gt;ax0&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imshow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img_org&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cmap&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gray&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vmin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vmax&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ax0&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_xlabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ssim_none&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;ax0&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Original image'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;ax1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imshow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img_png&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cmap&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gray&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vmin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vmax&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ax1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_xlabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ssim_png&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;ax1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'PNG'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;ax2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imshow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img_jpg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cmap&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gray&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vmin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vmax&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ax2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_xlabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ssim_jpg&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;ax2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'JPEG'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;show&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="png" src="https://cobra.pdes-net.org/images/ssim.png"&gt;&lt;/p&gt;</description><category>mathematics</category><category>presentations</category><category>web</category><guid>https://cobra.pdes-net.org/posts/image-quality.html</guid><pubDate>Sat, 02 Apr 2016 10:45:19 GMT</pubDate></item><item><title>Old habits</title><link>https://cobra.pdes-net.org/posts/old-habits.html</link><dc:creator>Cobra</dc:creator><description>&lt;h3&gt;Or: Recombination dynamics in a coupled two-level system with strong nonradiative contribution (&lt;a href="http://pdes-net.org/scripts/old_habits.tar.xz"&gt;an ipython notebook&lt;/a&gt;)&lt;/h3&gt;
&lt;p&gt;One of my students investigates the transient behavior of the &lt;a href="https://en.wikipedia.org/wiki/Photoluminescence"&gt;photoluminescence&lt;/a&gt; emitted by &lt;a href="https://en.wikipedia.org/wiki/Indium_gallium_nitride"&gt;(In,Ga)N&lt;/a&gt; quantum heterostructures after being irradiated by a short laser pulse. The characteristic feature of the transients he observes for these structures is a power-law decay of the photoluminescence intensity with time at low temperatures (10 K), which changes into an exponential decay at higher temperatures (150 K). &lt;/p&gt;
&lt;p&gt;His results reminded me of ones I acquired myself ages ago, during my own time as a PhD student. I didn't have a sensible interpretation then, but I do have one now. Hence, to the surprise of my student, I nonchalantly wrote down the following two coupled differential equations as if they had just occurred to me:&lt;/p&gt;
&lt;p&gt;${\dot n_b} = -n_b/\tau_{rel} - n_b/\tau_{nr} + n_w \exp(-\frac{E_b}{k_B T})/\tau_e$&lt;/p&gt;
&lt;p&gt;${\dot n_w} = n_b/\tau_{rel} - t^{b-1} n_w/\tau_{w} - n_w \exp(-\frac{E_b}{k_B T})/\tau_e$&lt;/p&gt;
&lt;p&gt;with the second term in the second equation ($t^{b-1} n_w/\tau_{w}$) being the experimental observable. The form of this term is giving rise to what is known as a &lt;a href="https://en.wikipedia.org/wiki/Stretched_exponential_function"&gt;&lt;em&gt;stretched exponential&lt;/em&gt;&lt;/a&gt;, which for $b \rightarrow 0$ approaches a power law for long times.&lt;/p&gt;
&lt;p&gt;Using Mathematica, it takes 7 lines of code to solve this system and to plot it for several temperatures $T$ (or, equivalently and as done here, for different energies $k_B T$):&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;IPython.display&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&gt;
&lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'/home/cobra/ownCloud/MyStuff/Documents/pdes-net.org/files/images/deqs.png'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="Mathematica" src="https://cobra.pdes-net.org/images/deqs.png"&gt;&lt;/p&gt;
&lt;p&gt;As I had hoped, this simple model reproduces the behavior observed in the experiment fairly well. My student was also pleased, but only with the result, not with the method: he's familiar with Matlab, but not with Mathematica. Well, I suspect that he's also not too familiar with Matlab, since he could otherwise have easily solved the equations himself.&lt;/p&gt;
&lt;p&gt;In any case, his admission reminded me that I actually wanted to migrate my computational activities to &lt;a href="http://pdes-net.org/cobra/posts/open-source-math.html"&gt;free software&lt;/a&gt;  whenever possible. It's not easy to get rid of old habits, and as I'm using Mathematica since 23 years, the code above just came naturally, while the one below still required an explicit intellectual effort. But that's essentially the same lame excuse which I'm tired to hear from users of, for example, Microsoft Office when asked to prepare a document with LibreOffice. &lt;/p&gt;
&lt;p&gt;So let's get moving. Here's the above differential equation system solved and plotted using numpy, scipy, and matplotlib in an ipython notebook. Note how the notebook integrates the actual code with comments, links, pictures and equations. Editing this notebook is a real treat thanks to the use of markdown and LaTeX syntax.  &lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="c1"&gt;#Initialize&lt;/span&gt;
&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;matplotlib&lt;/span&gt; &lt;span class="n"&gt;inline&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;matplotlib&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;mpl&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;plt&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;np&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;scipy.integrate&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;odeint&lt;/span&gt; 

&lt;span class="n"&gt;mpl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rcParams&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'figure.figsize'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;mpl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rcParams&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'font.size'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;
&lt;span class="n"&gt;mpl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rcParams&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'text.usetex'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;
&lt;span class="n"&gt;mpl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rcParams&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'font.family'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Serif'&lt;/span&gt;
&lt;span class="n"&gt;mpl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rcParams&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'lines.linewidth'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="n"&gt;mpl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rcParams&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'xtick.major.pad'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="c1"&gt;# Parameters&lt;/span&gt;
&lt;span class="n"&gt;taurel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;       &lt;span class="c1"&gt;# capture time&lt;/span&gt;
&lt;span class="n"&gt;taue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;         &lt;span class="c1"&gt;# emission time&lt;/span&gt;
&lt;span class="n"&gt;taunr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt;       &lt;span class="c1"&gt;# nonradiative lifetime&lt;/span&gt;
&lt;span class="n"&gt;tauw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.65&lt;/span&gt;        &lt;span class="c1"&gt;# radiative lifetime&lt;/span&gt;
&lt;span class="n"&gt;eb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;            &lt;span class="c1"&gt;# activation energy (in meV)&lt;/span&gt;
&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;              &lt;span class="c1"&gt;# stretching parameter (approaches power law for b -&amp;gt; 0)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="c1"&gt;# solve the system dn/dt = f(n,t) and plot the solution&lt;/span&gt;
&lt;span class="n"&gt;fig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;figure&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="c1"&gt;#for kt in np.linspace(1,13,7):          # approximate temperatures&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;70&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;          &lt;span class="c1"&gt;# exact temperatures&lt;/span&gt;

    &lt;span class="n"&gt;kt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.086173324&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;                   &lt;span class="c1"&gt;# in meV&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;nbt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="n"&gt;nwt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="c1"&gt;# the model equations&lt;/span&gt;
            &lt;span class="n"&gt;f0&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;nbt&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;taurel&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;nbt&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;taunr&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;nwt&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;eb&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;kt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;taue&lt;/span&gt;
            &lt;span class="n"&gt;f1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nbt&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;taurel&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;nwt&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;eb&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;kt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;taue&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;nwt&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;tauw&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;f0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="c1"&gt;# initial conditions&lt;/span&gt;
    &lt;span class="n"&gt;nb0&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.&lt;/span&gt;                            &lt;span class="c1"&gt;# initial population in barrier&lt;/span&gt;
    &lt;span class="n"&gt;nw0&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;                             &lt;span class="c1"&gt;# initial population in well&lt;/span&gt;
    &lt;span class="n"&gt;n0&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;nb0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nw0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;                     &lt;span class="c1"&gt;# initial condition vector&lt;/span&gt;
    &lt;span class="n"&gt;t&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;logspace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;         &lt;span class="c1"&gt;# logarithmic time grid&lt;/span&gt;

    &lt;span class="c1"&gt;# solve the DES&lt;/span&gt;
    &lt;span class="n"&gt;soln&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;odeint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;nb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soln&lt;/span&gt;&lt;span class="p"&gt;[:,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;nw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soln&lt;/span&gt;&lt;span class="p"&gt;[:,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="c1"&gt;# plot results&lt;/span&gt;
    &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loglog&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;nw&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;tauw&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;nw&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;tauw&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="si"&gt;%.0f&lt;/span&gt;&lt;span class="s1"&gt; K'&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xlabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Time (ns)'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ylabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Intensity (arb. units)'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;axis&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mf"&gt;7e-3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;1e-5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;legend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'lower left'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frameon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prop&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'size'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="n"&gt;labelspacing&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="ipython" src="https://cobra.pdes-net.org/images/transients.svg"&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;fig&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;savefig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'transients.pdf'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The above command saves this plot as a publication-ready figure in pdf format. There are many other available formats, including eps (for the traditional LaTeX/dvipdf toolchain), svg (for further editing with inkscape, or publishing in the web) and png (for insertion in a Powerpoint/Impress presentation). &lt;/p&gt;</description><category>mathematics</category><category>presentations</category><category>web</category><guid>https://cobra.pdes-net.org/posts/old-habits.html</guid><pubDate>Sun, 18 Oct 2015 12:09:14 GMT</pubDate></item><item><title>Enough is not enough</title><link>https://cobra.pdes-net.org/posts/enough-is-not-enough.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;People like to tell me about their digital life. Recently, I hear a lot about laptops replacing desktops. To my surprise, many are willing to spend quite a bit for this transition: most more than €1000 and some €2000 and above. All of the former assure me that the performance of their desktop replacement is "more than enough". Several of the latter actually believe that the system's performance is directly related to its pricetag. One member of this group owns a Macbook 12 (sorry for the cliché, but what can I do) and tried to convince me in a particular insistent and tenacious way that his gadget would outperform even the most powerful desktops available.&lt;/p&gt;
&lt;p&gt;As a matter of fact, it is quite far from this feat (look &lt;a href="http://www.notebookcheck.net/Mobile-Processors-Benchmark-List.2436.0.html"&gt;here&lt;/a&gt;). As all ultrabooks equipped with a Core M-5YXX processor, it performs slightly better (20–40%) than my €299 Fujitsu Lifebook which, however, is miles away from a decent desktop:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="https://cobra.pdes-net.org/images/ycruncher_deepgreen.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="https://cobra.pdes-net.org/images/ycruncher_blackvelvet.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="https://cobra.pdes-net.org/images/ycruncher_osmium.png"&gt;&lt;/p&gt;
&lt;p&gt;Right, the last one is not your usual desktop, but a compute server with—at the moment of the screenshot—a load of 24. The remaining 8 physical cores managed to outperform my desktop, if only by a slight margin. But I bet that my new office desktop (an i7 4790) will be able to complete the run under 100 s ... let's see tomorrow. 😉&lt;/p&gt;
&lt;p&gt;Update: even below 80 s:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="https://cobra.pdes-net.org/images/ycruncher_pdi282.png"&gt;&lt;/p&gt;
&lt;p&gt;In any case, my lifebook has been thoroughly smashed and humiliated: instead of the 2 minutes required by the Xeons it needed a staggering 20 minutes for the same result. The lifebook is great for writing this entry, but for serious tasks I rather turn to a serious computer. And the same applies to your Core M driven ultrabooks.&lt;/p&gt;
&lt;p&gt;At this point, the compassionate ones of the laptop owners are sure to secretly pity me. Just imagine that I have to stay all time in a kind of server room for being able to take advantage of the performance depicted above. ... how gruesome!&lt;/p&gt;
&lt;p&gt;Well, as much as I &lt;a href="http://pdes-net.org/cobra/posts/season-color.html"&gt;like to sit in my study&lt;/a&gt;, I prefer to run my computations from where I want. How do I do that?&lt;/p&gt;
&lt;p&gt;I have WiFi. 😄&lt;/p&gt;
&lt;p&gt;Seriously, for computations I use an ipython server running on my desktop. The posts of &lt;a href="https://blog.filippo.io/my-remote-shell-session-setup/"&gt;Fillipo&lt;/a&gt; and &lt;a href="https://coderwall.com/p/ohk6cg/remote-access-to-ipython-notebooks-via-ssh"&gt;Nikolaus&lt;/a&gt; have helped me to find the best (most robust and convenient) way to connect to this server. &lt;/p&gt;
&lt;p&gt;For what follows, both the server and the client need to have &lt;a href="https://mosh.mit.edu/"&gt;mosh&lt;/a&gt; installed. For the server, &lt;a href="http://tmux.sourceforge.net/"&gt;tmux&lt;/a&gt; (which I also like to use for &lt;a href="http://pdes-net.org/cobra/posts/command-center.html"&gt;different reasons&lt;/a&gt;) is required in addition.&lt;/p&gt;
&lt;p&gt;From the client, I connect to the server (blackvelvet) by issuing&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;mosh blackvelvet -- tmux new-session -s ipython
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In this session, I then start an ipython notebook server on blackvelvet:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;ipython notebook --no-browser --port=8889
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;and subsequently detach the session with Ctrl-a d. &lt;/p&gt;
&lt;p&gt;I can attach again anytime by issuing &lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;mosh blackvelvet -- tmux a
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;on the client. Isn't that neat?&lt;/p&gt;
&lt;p&gt;To connect to the server, I start an ssh tunnel on the client with&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;ssh&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;L&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;localhost&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;8888&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="nl"&gt;localhost&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;8889&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;cobra&lt;/span&gt;&lt;span class="nv"&gt;@blackvelvet&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;and open the notebook at &lt;a href="http://localhost:8888/"&gt;http://localhost:8888/&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="https://cobra.pdes-net.org/images/ipython_server.png"&gt;&lt;/p&gt;
&lt;p&gt;Thanks to &lt;a href="http://pdes-net.org/cobra/posts/scalable.html"&gt;MathJax&lt;/a&gt;, the font rendering is way better than that of Mathematica.&lt;/p&gt;
&lt;p&gt;The ssh tunnel can be stopped with a single Ctrl-C on the client, the ipython server needs a double one on the server (after attaching the session again). &lt;/p&gt;</description><category>hardware</category><category>mathematics</category><guid>https://cobra.pdes-net.org/posts/enough-is-not-enough.html</guid><pubDate>Mon, 25 May 2015 17:26:56 GMT</pubDate></item><item><title>Sculpting</title><link>https://cobra.pdes-net.org/posts/sculpting.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;Suppose we have a crystal in the form of a rectangular block, given by a list of the absolute atomic coordinates with one atom per line &lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;Ga   -9.278018850000   -9.642000000000   -7.870137870000
N    -7.422415050000   -9.642000000000   -8.518637230000
.
.
.
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;looking like that:
&lt;img alt="" src="https://cobra.pdes-net.org/images/block.png"&gt;&lt;/p&gt;
&lt;p&gt;What we really want, though, is a hexagonal column which tapers down from the bottom to the top — just like a column of &lt;a href="http://en.wikipedia.org/wiki/Doric_order"&gt;Doric order&lt;/a&gt;. How can we sculpt this column out of the block we have? Where do we get the digital chisel we need? A &lt;a href="https://scholar.google.de/citations?user=p3b43FsAAAAJ&amp;amp;hl=en&amp;amp;pagesize=100"&gt;colleague of mine&lt;/a&gt; solved this quest in the most elegant fashion: with an awk one-liner.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;awk '{x=sqrt($2^2);y=sqrt($3^2);d=x/2+sqrt(3)/2*y;z=$4;cutoff='$radius1'*('$zmax'-z)/'$zrange'+'$radius2'*(z-('$zmin'))/'$zrange'};d&amp;lt;=cutoff &amp;amp;&amp;amp; x&amp;lt;cutoff' block.dat &amp;gt; column.dat
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Voilà:
&lt;img alt="" src="https://cobra.pdes-net.org/images/column.png"&gt;&lt;/p&gt;</description><category>linux</category><category>mathematics</category><category>presentations</category><guid>https://cobra.pdes-net.org/posts/sculpting.html</guid><pubDate>Sat, 02 May 2015 11:23:57 GMT</pubDate></item><item><title>Having fun with classical ciphers</title><link>https://cobra.pdes-net.org/posts/having-fun-with-classical-ciphers.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;&lt;strong&gt;19.12.2013&lt;/strong&gt;&lt;br&gt;
 I've written most of what follows three years ago, but I've never found the time to finish and post it. As usual this close to Christmas, I have a few days off, and took the opportunity to delve once again into the fascinating world of classical ciphers. :cheesey:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;27.12.2010&lt;/strong&gt;&lt;br&gt;
 The millenia-old war between code-makers and code-breakers has essentially stopped in the last century: modern ciphers are so strong that they just can't be broken in any humanly accessible time-span. &lt;a href="http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange" title="Diffie, Hellmann, and Merkle"&gt;Diffie, Hellmann, and Merkle&lt;/a&gt; solved the key exchange problem, &lt;a href="http://en.wikipedia.org/wiki/Phil_Zimmermann" title="Phil Zimmermann"&gt;Phil Zimmermann&lt;/a&gt; gave encryption to the masses, and the GnuPG project transferred Zimmermanns 'Pretty Good Privacy' to the open source world.&lt;/p&gt;
&lt;p&gt;End of story. Or is it?&lt;/p&gt;
&lt;p&gt;Well, for most practical applications, that's basically it. We can trust that either of the following commands&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;gpg -ca --passphrase-repeat 0 --cipher-algo aes256 &amp;lt;file&amp;gt;
gpg -sea -r cobra &amp;lt;file&amp;gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;results in an encrypted file whose content will be inaccessible to even the most nosy of our sniffing and snooping friends. Unless, of course, they revert to &lt;a href="http://imgs.xkcd.com/comics/security.png" title="alternative ways"&gt;alternative ways&lt;/a&gt; of collecting information. :P&lt;/p&gt;
&lt;p&gt;People had this particular problem since the beginning of time and invented &lt;a href="https://cobra.pdes-net.org/posts/chop-off-your-heads.html" title="steganography"&gt;steganography&lt;/a&gt;. Nowadays, one can can easily hide and encrypt information in one and the same command:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;steghide embed -e rijndael-256 -z 9 -cf &amp;lt;coverfile&amp;gt; -ef &amp;lt;embeddedfile&amp;gt;; -sf &amp;lt;combinedfile&amp;gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;All right, so where's the catch?&lt;/p&gt;
&lt;p&gt;My itch with modern ciphers is not a practical one. I rather find their mathematical foundation abstract and dry, although I can digest most of it when I try really hard. However, you can't possibly utilize modern encryption without a computer.&lt;/p&gt;
&lt;p&gt;Ancient ciphers, in contrast, are often intuitive and easy to master by paper and pencil. And what's more, ancient ciphers are surrounded by a mystical and glorious aura. Just think of the &lt;a href="http://en.wikipedia.org/wiki/Enigma_machine" title="Enigma"&gt;Enigma&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;When I was a kid, Diffie and Hellman as well as &lt;a href="http://en.wikipedia.org/wiki/RSA_(cryptosystem)" title="Rivest, Shamir and Adleman"&gt;Rivest, Shamir and Adleman&lt;/a&gt; still chased attractive female students across the campus. There was no modern cryptography, just an afterglow from the war. There were only a handful of computers, and hardly any of them in public possession. Being a nerdy kid, I became member of the local chess club with age eight. People there talked a lot about chess, but also about encryption, and the atmosphere turned out to be infectious. I adored Edgar Allan Poes &lt;a href="http://en.wikipedia.org/wiki/The_Gold-Bug" title="Gold Bug"&gt;Gold Bug&lt;/a&gt; as well as Arthur Conan Doyles &lt;a href="http://en.wikipedia.org/wiki/The_Adventure_of_the_Dancing_Men" title="Adventure of the Dancing Men"&gt;Adventure of the Dancing Men&lt;/a&gt;. I was thrilled to death by Vigenère's &lt;a href="http://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher" title="Le chiffre indéchiffrable"&gt;Le chiffre indéchiffrable&lt;/a&gt; (French for 'the indecipherable cipher'). And I would have died for book ciphers. The &lt;a href="http://en.wikipedia.org/wiki/Beale_ciphers" title="unbreakable type"&gt;unbreakable type&lt;/a&gt;, you know.&lt;/p&gt;
&lt;p&gt;And now over Christmas, I thought, aw what the hell ... let's just play with all that's fun! Being fascinated by the Vigenère cipher, I sat down and implemented it using the only programming language I've ever learned: &lt;a href="http://en.wikipedia.org/wiki/Pascal_(programming_language)" title="Pascal"&gt;Pascal&lt;/a&gt;. And since we don't have to fill the _tabula recta _ourselves anymore, I've generalized the classical scheme to the entire 95 letter alphabet of the &lt;a href="https://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters" title="ASCII printable characters."&gt;ASCII printable characters.&lt;/a&gt; That took me an entire day, but my Pascal courses took place almost 30 years ago. 😞&lt;/p&gt;
&lt;p&gt;A Vigenère cipher can be as strong as desired. If the key is as long as the message, and truly random, it constitutes an example of a &lt;a href="http://en.wikipedia.org/wiki/One-time_pad" title="one-time pad"&gt;one-time pad&lt;/a&gt; (OTP), the only cipher which is information-theoretically proven to be unbreakable. Despite of this fact, OTPs have been rarely used in the past since key distribution proved to be an insurmountable problem.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Quantum_key_distribution" title="Quantum key distribution"&gt;Quantum key distribution&lt;/a&gt; has solved this problem in principle, but is not (yet) for everyone. Still, if the number of people on a communication channel is limited, the distribution of an OTP is easier than ever. Remember than one A4 page of text roughly corresponds to 3 kB. The 2 GB of an average USB stick would thus suffice for 700,000 of such pages, which should be enough for even the most communicative individuals. 😉&lt;/p&gt;
&lt;p&gt;True randomness, however, is an requirement not easily obtained at all, since only natural phenomena such as &lt;a href="http://random.org" title="atmospheric noise"&gt;atmospheric noise&lt;/a&gt; or &lt;a href="http://www.fourmilab.ch/hotbits/" title="radioactive decay"&gt;radioactive decay&lt;/a&gt; are truly random. A computer, instead, is a deterministic beast and can only generate pseudo-random numbers. The "best" algorithms for doing that are called 'cryptographically secure pseudo-random number generators' (CSPRNG), but even these are predictable to a certain degree. I consider the &lt;a href="https://code.google.com/p/csrng/" title="one I'll use in the following"&gt;one I'll use in the following&lt;/a&gt; to be a very solid contender, but not necessarily the best (for which &lt;a href="http://en.wikipedia.org/wiki/Blum_Blum_Shub" title="Blum-Blum-Shub generators"&gt;Blum-Blum-Shub generators&lt;/a&gt; may qualify, though they are slow, and there's no readily available open-source implementation anyway).&lt;/p&gt;
&lt;p&gt;How do we judge the quality of a CSPRNG? One of the most popular battery of tests are compiled in the &lt;a href="https://aur.archlinux.org/packages/dieharder/" title="dieharder"&gt;dieharder&lt;/a&gt; suite, a successor of George Marsaglia's famous &lt;a href="http://en.wikipedia.org/wiki/Diehard_tests" title="diehard tests"&gt;diehard tests&lt;/a&gt;. This suite interfaces to the continuous stream of random numbers of the generator, here &lt;a href="https://code.google.com/p/csrng/" title="csrng,"&gt;csrng,&lt;/a&gt; like that:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;csprng-generate | dieharder -g 200 -a
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Two tests were indicated as "weak", but that turned out to be a result of the limited statistics with the default settings of dieharder.&lt;/p&gt;
&lt;p&gt;We can also examine a finite list of random numbers created by such a generator. An infinite perfectly random sequence would exhibit an entropy per character equal to &lt;em&gt;S&lt;/em&gt;=log2(&lt;em&gt;k&lt;/em&gt;), where &lt;em&gt;k&lt;/em&gt; is the character space. We will come back to that later.&lt;/p&gt;
&lt;p&gt;A Vigenère cipher used in conjunction with a pad generated by a CSPRNG is an example for a &lt;a href="http://en.wikipedia.org/wiki/Running_key_cipher" title="running key cipher"&gt;running key cipher&lt;/a&gt;, but one could equally well call it a pseudo one-time pad (POTP). Depending on the cryptographic quality of the CSPRNG used, it may be trivial or essentially impossible to break. It will never be an &lt;a href="http://en.wikipedia.org/wiki/Information_theoretic_security" title="information-theoretical secure system"&gt;information-theoretical secure system&lt;/a&gt; such as the OTP, but it may approach a level of security similar to that offered by modern cryptographic techniques.&lt;/p&gt;
&lt;p&gt;My little Pascal routine in conjunction with the POTP created by &lt;a href="https://code.google.com/p/csrng/" title="csrng"&gt;csrng&lt;/a&gt; is perfectly capable of encrypting pure ASCII data, but can't handle anything beyond such as extended ASCII, UTF-8 or binary data. To improve on that, I preprocess the 'plaintext' (which may also be an image or an executable) with &lt;a href="http://base91.sourceforge.net/" title="base91"&gt;base91&lt;/a&gt; to obtain a well-defined character set regardless of the file type.&lt;/p&gt;
&lt;p&gt;Finally, I need to cut a section of the POTP serving as the key for each respective message, and to subsequently shred this section so it cannot be used again. All of that is easily done by a short shell script. Let's examine the essential ingredients of this script (in pseudo script code, for the actual one, see below):&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;csprng-generate -n 4G | tr -cd '[:graph:]' | fold -w 65 &amp;gt; POTP
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Creates a stream of random numbers with a total volume of 4 GB. The binary stream is filtered through 'tr', letting pass only printable ASCII characters. These characters are then arranged in lines of 65 characters length and saved as our POTP. On my desktop, this command takes about 35 s to complete.&lt;/p&gt;
&lt;p&gt;Let's now look at the encryption part (decryption is largely the same, just the order is different):&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;b91enc -w 65 PLAINTEXT -o ENCODEDTEXT
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Encodes the PLAINTEXT with base91, and ensures that the ENCODEDTEXT has the same format as the POTP or the key.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;tail -n NUMBER POPT &amp;gt; KEY
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Generates the key (NUMBER is determined by the length of the ENCODEDTEXT, see the shell script for details).&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;vig -e ENCODEDTEXT KEY &amp;gt; ENCRYPTEDTEXT
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Encrypts.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;truncate -s KEY POTP
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Removes the KEY from the POTP.&lt;/p&gt;
&lt;p&gt;All of that is pretty straightforward except for the strange fact that I get the KEY from the bottom of the file rather than from the top, which would be the intuitive choice for a 'pad'. The reason for this choice is very simple: removing the key from the bottom takes 1 ms, but from the top several seconds depending on the speed of the hard disk. This asymmetry is an inevitable consequence of the file system's way to store data. With the present 'backward' scheme, the total time for the steps 1. — 4. amounts to 30 (450) ms for an A4 text page (a 5MB pdf).&lt;/p&gt;
&lt;p&gt;Let's examine the files created by these steps using John Walker's entropy estimator &lt;a href="http://www.fourmilab.ch/random/" title="ent"&gt;ent&lt;/a&gt;. For the 95 characters used here, a perfectly random and infinite sequence of numbers is expected to have an entropy of 6.570 bit per character. For our POTP as well as for the plaintext encrypted with it, ent arrives at an entropy of 6.569 bits per character.&lt;/p&gt;
&lt;p&gt;That's pretty satisfactory, but let's have a closer look. Deviations from randomness are often plainly evident in a &lt;a href="http://www.random.org/analysis/" title="visual inspection"&gt;visual inspection&lt;/a&gt; of the data in question. For example, we can examine the distribution of characters in our POTP using&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;ent -c POTP | head -97 | tail -94 | awk '{print $3}'&amp;gt; hist.dat
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Plotting these values yields a histogram of the character distribution:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cobra.pdes-net.org/images/hist_potp.png" width="300"&gt;&lt;img src="https://cobra.pdes-net.org/images/hist_dev_potp.png" width="300"&gt;&lt;/p&gt;
&lt;p&gt;Looks almost entirely equally distributed, as we had hoped. However, in a finite random sequence, fluctuations do occur which can be made visible by plotting the deviation of each value from the mean of the distribution. Besides the fact that the values are small (the standard deviation is indeed only 0.02%), these deviations do not form any obvious pattern, but look indeed random.&lt;/p&gt;
&lt;p&gt;We can perform the same analysis for the data after being encrypted by the Vigenère routine:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cobra.pdes-net.org/images/hist_enc.png" width="300"&gt;&lt;img src="https://cobra.pdes-net.org/images/hist_dev_enc.png" width="300"&gt;&lt;/p&gt;
&lt;p&gt;The fluctuations are larger (standard deviation 0.4%) since the sample size is significantly smaller, but once again the data do not exhibit any obvious deviations from a random distribution.&lt;/p&gt;
&lt;p&gt;To analyze these data, by the way, I've used only the ipython console (ipython --pylab) and a few pylab commands:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;loadtxt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'hist.dat'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;arange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;94&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;For sake of clarity and documentation, I've &lt;a href="http://pdes-net.org/scripts/hfwcc.tlz" title="attached an archive"&gt;attached an archive&lt;/a&gt; containing the shell script hfwcc and the Pascal routine vig.pas. For the former, I've disabled truncation as this feature forfeits local testing (it should only be used with two independent POTPs). For convenience, I've included a 64 bit binary of the latter compiled with &lt;a href="http://www.freepascal.org/" title="fpc"&gt;fpc&lt;/a&gt; 2.6.2. The encoding tool &lt;a href="https://aur.archlinux.org/packages/base91" title="base91"&gt;base91&lt;/a&gt;, the random number generator &lt;a href="https://aur.archlinux.org/packages/csprng/" title="csnrg"&gt;csnrg&lt;/a&gt; and the analysis program &lt;a href="https://aur.archlinux.org/packages/ent/" title="ent"&gt;ent&lt;/a&gt; are all available in the AUR (Arch User Repository). I'd expect you'll also get them for Debian, but users of other distributions will probably have to compile them themselves.&lt;/p&gt;</description><category>archlinux</category><category>encryption</category><category>linux</category><category>mathematics</category><guid>https://cobra.pdes-net.org/posts/having-fun-with-classical-ciphers.html</guid><pubDate>Thu, 19 Dec 2013 16:11:23 GMT</pubDate></item></channel></rss>