#balisebooks – February 2019

(Version française ici : #balisebooks – Février 2019)

Short month, short !

Slayer – Kiersten White

I’m a huge fan of Buffy the Vampire Slayer… the TV series, that is. I could never quite get into the comics – to my great dismay, because I really want to know the story, but comics are definitely not my medium of choice. So you’ll understand my excitement when I heard “this is a novel set in the canon timeline of BTVS, although with a different cast of characters”. The hype was real, and I was in the mood for a lighter read, so I picked Slayer pretty close to its publication date.

Besides the initial premise, we meet Nina and her twin sister Artemis, both part of a larger “Watcher Academy” that aims at training Watchers for Slayers, as well as providing some infrastructure and services. The plot then loosely follows the structure of a long BTVS episode, or maybe a long multi-episode arc. I had initial misgivings at the beginning of the book: Nina hates Buffy and Slayers in general, and I think that, if the tone there and the amount of repetitive brooding had stayed the same, it would have been a problem. But the pace eventually picked up, and gave way to what really felt like a multi-episode arc story, with demons, villains, libraries, family and friendly relationships, and a non-zero amount of wit.

All in all, I enjoyed Slayer, and I think it’s a good addition to the BTVS canon. Looking forward to the next one! (Also: in the meantime, I started re-watching Buffy :P)

Cork Dork: A Wine-Fueled Adventure Among the Obsessive Sommeliers, Big Bottle Hunters, and Rogue Scientists Who Taught Me to Live for Taste – Bianca Bosker

Cork Dork is a memoir about the journey of Bianca Bosker, initially a tech reporter, who made her way through the world of wine tasting and wine serving. She recounts how she came to that idea, the people she met, all the things she learnt about wine, and how she went from basically “yup, that’s wine, and I think it’s white wine” to taking a Master Sommelier exam within a bit more than a year.

Bosker makes her journey memorable – she’s not afraid to show how clueless and clumsy she may have been, but she shows tremendous grit and a real passion for her topic. I’m thoroughly impressed and a little bit jealous 🙂 She also gives some actionable information about how to get better at smelling and tasting things, and I’m intrigued enough that I may give some of them a try. (Hell, I went to the restaurant the other day and I did choose the wine glass I really didn’t know on the menu, so there’s that 😉 ). Her writing is very engaging, although I found myself slightly distracted at times when I literally heard a few “transition questions” read in my mind by Carrie Bradshaw 😛

I thoroughly enjoyed Cork Dork: it opened the door to a world I do not know, and made me want to hazard a foot through it 🙂

Meet Me at the Museum – Anne Youngson

Tina, a farmer’s wife in England, writes a letter to a museum in Denmark, and the curator of the museum, Anders, answers her letter. It’s the start of a long correspondance that constitutes the whole book.

I haven’t read that many epistolary novels, but I seem to enjoy the form a lot – maybe I should read more of them 🙂 In this one, I liked the fact that the people involved are complete strangers at the beginning of the book and in pretty different places, which is a perfect justification for very vivid descriptions as the writers explain their environment to each other. Generally speaking, the writing is beautiful and the voices of Tina and Anders are pretty distinct. The first 80% felt very sweet and very restful to me, although by no mean boring. I was, however, not happy with the developments of the last 20% of the book (although I liked the very end), because I felt that the tone became suddenly more judgmental and I didn’t care for that; that part also felt more rushed and I didn’t care for that either.

Everything considered, it was still a “more than 80% positive read”, but I’m sad that the part I didn’t like really didn’t work for me.

Cibola Burn – James S.A. Corey

The titles of the Expanse books’ series are somewhat cryptic, and Cibola Burn is not an exception – and on top of that, I cannot read that and not think “cinnamon buns”. There, you’re welcome.

This is the fourth book of The Expanse, and the premise of it is very much a spoiler on the previous book – I don’t see how I can avoid that if I want to explain the premise. So, beware:

SPOILERS ON ABADDON’S GATE, THE THIRD BOOK OF THE EXPANSE, AHEAD!

The Ring from the previous book ended up being an inter-solar system traveling gate, so we’re going to (larger) space today! I must admit I was a bit disappointed by that development in the previous book – I really liked, in the first three books, that the plot stayed in our solar system. Hence, I was afraid to not like this one as much as the previous ones. I shouldn’t have feared: I actually liked it better than the third one.

So, a bunch of people have rushed through the gate and started a colony on Ilus / New Earth; since the planet is rich in lithium, it is also very relevant to corporate interests. Said corporate interests are RCE, and they have a Proper Colonization Charter, and they’re not going to get stopped by a bunch of squatters on The Planet That’s Rightfully Theirs. The situation escalates, and Jim Holden and his crew are sent to try to de-escalate.

LESS SPOILERY CONTENT AHEAD

We get a fair amount of what made the first books memorable: the mix of old friends and new characters, the multiple point of views narration, the drama and action (although the scale seems reduced here). The setting is basically “frontier, but IN SPACE and with SCIENTISTS”, and it was very enjoyable. Cibola Burn was hard to put down (I may or may not have made the VERY BAD DECISION to finish it last night and to continue reading past midnight) and managed the transition to the larger setting flawlessly. It can feel somewhat formulaic at times, but the formula definitely works for me, so everything’s shiny.

52Frames – 2019 Week 07 – Uncommon

The theme for 52Frames this week was Uncommon. I’ll admit that this kind of theme is not necessarily my cup of tea, because I find it too wide. And the extra credit “Portrait of a stranger” gets “all the nopes” from me, so that didn’t work as a “helpful restriction”.

Thankfully, we had a very nice full-moon this week – a “supermoon”, even (I missed the completely full moon, but oh well), and it happened to hide behind my neighbour’s balcony when it first rose. I thought the Moon “trapped” in a prison-like grid was uncommon enough to submit it for this week’s theme 🙂

The shot itself was not very difficult – my cheap Sigma telephoto lens is actually good enough to get reasonable results, both in terms of exposure (f/11, 1/250ms, ISO adjusted as required) and in terms of focus – that’s really the hard part, but I think I’m getting the gist of it now (yay for focus peaking and live view zoom!).

Marzipan update – now with context menu!

It may seem trivial, but I unlocked an achievement on Marzipan: I added a menu. I’ve been wanting to have a few “quality of life” improvements for a while now, but so far I had been hiding under the duvet of “I really don’t want to touch the UI/Qt code more than I strictly have to”.

My experience with graphical toolkits in general has never been great. It’s really out of my comfort zone; I tend to find that the tutorials on the Internet don’t have anything between an equivalent of “Hello, World!” and an equivalent of “here’s some advanced quantum mechanics” (I do suck at physics in general as well); I kind of have the impression that my use cases are dead simple and should just Be Available As Is and that For Sure I Don’t Need To Read All That Documentation. (Yeah, yeah, I may be somewhat guilty here.) And I get upset and impatient, and generally speaking it’s not a good experience – neither for myself nor for anyone else in the room. (My apologies to my husband!)

But when you’re the only coder and the only user of a project, at some point biting the bullet gets inevitable. Consequently, in the last pull request, I did a fair amount of refactoring. When I started my coding session, everything was contained in a QWindow, in which I was painting an image directly on the QBackingStore. I then read a bunch of stuff about menus, which made me update my QWindow to a QMainWindow – for which the QBackingStore seems less trivially accessible, so I modified that. But then, the refresh was only working when resizing the window, which kind of sucked (and I’m still not entirely sure why). So I put a QWidget inside my QMainWindow as a main widget, and that allowed me to have both the refresh and the menu – yay! I needed to tinker a bit more to get back the keyboard control (move them from the QWidget to the QMainWindow), and now it’s all nice and shiny.

The undo/redo function itself is basically storing the fractal parameters in a couple of stacks and re-computing on undo/redo – nothing fancy (and my memory management is utter shit – read “nonexistent”, I really need to fix that – and I don’t handle storing the orbits properly yet, but one thing at a time.)

As a result: I do have at least half-functional Undo/Redo, and more importantly, I have a reasonable base for future UI/QoL development: I hope that the major hurdle of figuring out how things might fit together is behind me, and I’m a bit less scared of it.

I can’t say I’m happy with that session, because I still have the impression that I tried to put stuff together while having no idea what I’m doing, and while having the impression that I’m not actually learning anything in the process, but this may actually be better than I think. We’ll see 🙂

Planarity, minors and donuts

Ce billet est la traduction d’un billet écrit initialement en français : TPA – Planarité, mineurs et donuts.

Let’s have a little bit of graph theory today – I want to present (without a proof) a fun result about graph planarity. Which means – first, let’s define a few things and draw a few pictures.

A graph is a set of vertices (“points”) connected by edges. To describe a graph, I can say “the set of vertices is labeled 1, 2, 3, 4 and 5, and I have edges between edges 1 and 2, 2 and 3, 3 and 4, 4 and 1, 1 and 3, 2 and 4, 1 and 5, and 4 and 5”. I can also draw it on a sheet of paper, and I can draw that statement in different ways: all the drawings here are drawings of the graph I just described.

In these three drawings, two of them are plane: the graph is drawn such that edges of the graph do not cross. The first drawing is not plane: the edges 1-3 and 2-4 are crossing. A graph that can be drawn in the plane (that is to say, on a flat piece of paper) such that no two edges cross is called a planar graph. The fact that we have an adjective for such a graph should tell you that there exists non-planar graphs: graphs that cannot be drawn in the plane without crossing two edges. Two typical (and useful) examples are the complete graph on 5 vertices (5 vertices, and all possible edges) – denoted K_5, and the complete bipartite graph on 3×2 vertices (2 groups A and B of three vertices, and all possible edges between vertices of group A and vertices of group B), denoted K_{3,3}. Here are their “usual” drawings; as we saw in the previous figure, these drawings are not unique. But you can search for a long long time for a drawing where no two edges cross (and not find it).

And there is a theorem (Wagner, 1937) that says that if a graph is not planar, it’s because somewhere in its structure it contains something that looks like K_5 or K_{3,3}. More precisely:

A finite graph is planar if and only if it does not have K_5 or latex K_{3,3} as a minor.

Okay, I cheated a bit, because I haven’t defined minor yet. So let’s do that:

A minor of a graph G is a graph that is obtained from G by doing any number of the following operations: removing an edge; removing a vertex; contracting a vertex.

Removing an edge is easy: if two vertices are connected by an edge, we can decide that in fact they aren’t, and remove the edge. Removing a vertex is also easy: pick a vertex, remove it, and remove all the edges that are connected to it, because otherwise we don’t know where they’re going anyway. Contracting a vertex is a tiny bit more complicated: the idea is that we pick two vertices that are connected with an edge, and we “merge” them in a single vertex. The resulting vertex is connected to all the edges of the initial two vertices that were in the original graph. One can imagine “pinching” the two vertices that get closer and closer until BOOM they fuse together. For a small example, in which I contract the vertices connected by the red edge in a single vertex:

So what Wagner says is: “if I fiddle with a graph a bit and I manage to obtain K_5 or K_{3,3}, then I cannot draw the graph without crossing edges. But if I cannot get K_5 or K_{3,3}, then I can draw the graph without crossing.”

There’s a theorem that expands this idea of “forbidden minors”. It’s a theorem by Robertson and Seymour, and its proof spans over 20 papers, published from 1984 to 2003. The theorem is stated as follows:

Every family of graphs that is closed under minors can be defined by a finite set of forbidden minors.

Let’s explain. A family of graphs that is closed under minors is a set of graphs such that, if I take any graph in this family, and I take a minor of it (with the aforementioned definition), then the minor is also in that set of graphs. What Robertson and Seymour say is that, in such a family, there exists a finite set of forbidden minors: if a graph has a minor of that set, then that graph is not part of the family.

Wagner’s theorem is a restriction of Robertson-Seymour for planar graphs. Planar graphs are a family of graphs that is closed under minors: if I take a minor of a planar graph, I can still draw that minor without crossing any edge, so it is planar as well. And there is a finite set of forbidden minors, specifically K_5 or K_{3,3}: if I find one of these minors in a graph, then the graph is not planar. Wagner, for the case of planar graphs, actually states the forbidden minors explicitly, which Robertson-Seymour does not.

And that’s the fun part: in general, we do not know the forbidden minors in question. We know they exist; we know there’s a finite number of them, but we do not know which they are. And, for a tiny example as a conclusion of this post: suppose now that I want to draw a graph not on a sheet of paper, but on a torus – or, if you want, on a donut.

The idea would be to draw vertices on a donut, and to connect them with edges, exactly as I do in the plane. If I do that, and I can draw the graph without crossing edges, the graph is not planar anymore, but toroidal (or donutoidal if you want). The family of toroidal graphs is closed for minors, so there exists a set of forbidden minors for this family. So far, 17523 have been found. It is yet unknown how many there are in total. Fun, isn’t it?

(And if you want to find them all, you may want to start by making donuts.)

52Frames – 2019 Week 07 – City at Night

The theme for 52Frames this week was “City by Night” with an extra credit “5 seconds or longer”. So I took my tripod outside of the apartment for the first time – which made me conclude that, although I do love my Manfrotto for studio work, I definitely need a more portable tripod if I want to move around with it.

I started my walk at Lindenhof to get a view of the Limmat, the University and ETH.

I also got a picture of a rare ghost tram!

On the other side, Grossmünster and the colorful lights from the Kantonspolizei building.

Then, I strolled along the Limmat, taking the picture that’s on top of this post (and that I submitted for 52Frames), as well as this more accidental one (I probably shot in the tripod in the middle of the exposure, although I don’t remember it…), that I ended up liking quite a lot 🙂

I ended my stroll at the lake, looked at the pier…

… as well at the other side of the view in direction of the Opera.

I believe that, for a first try at tripod night photography, it was pretty good. The pictures I got are not very original, but they’re from a technical point of view not bad, and I’m even happy with them 🙂

All of these were exposed at 30 seconds on ISO 100 and with a f/stop that would allow me to get a reasonable exposure (f/13, f/14 for these ones, although I experimented a bit more than that). Hardware-wise, my Pentax K-1, mounted with my 24-70/2.8, my Manfrotto 055 tripod with a ball head. I had a neutral density filter in my backpack because I didn’t know what would be the conditions for “long exposures” (which I wanted), but I didn’t need it. Oh, and a cable release – I wouldn’t have expected to use the remote and the cable release as much as I do when I bought them 🙂

The full album (which I posted in its entirety here) is available here: Zürich by Night – February 2019.

Cool stuff

Elemental haiku [interactive text] – a periodic table with haiku associated to every element. Cute 🙂

Juno image gallery [images] – images from the NASA Juno mission, orbiting Jupiter. I sense some of these will eventually end up in my desktop wallpaper images.

Winners of the 2019 International Garden Photographer of the Year Competition [images] – some very pretty garden-related pictures. Slightly larger res pictures (and more of them) are available on the contest website: International Garden Photographer of the Year.

A robot that teaches itself to play Jenga [text, video] – I like robots that do cool stuff. Playing Jenga is cool. (Or, at least: watching a robot playing Jenga is cool.)

Divisive factorials! [text] – some fun considerations about the question “what happens if we replace the multiplication by the division in the definition of the factorial?”. Part of the answer is: “it depends how you do that.”

Opportunity did not answer NASA’s final call, and it’s now lost to us [text] – Opportunity was declared lost this week, and it’s strangely emotional. I actually learnt it via XKCD: Opportunity Rover [comic], which may be the most moving XKCD in a while. Generally speaking: I think that’s the first time I read an obituary for a robot.

Bohemian Git-sody [text] – a re-writing of Bohemian Rhapsody lyrics around Git. Very relatable.

Intro to probability theory – part 2

Ce billet a été traduit de sa version originale en français : Probabilités – Partie 2.

After the previous post about probability theory, here’s the second part, in which I’ll talk about random variables.

The idea of random variables is to have some way of dealing with events for which we do not exactly what happens (for instance, we roll a die), but still want to have some idea of what can happen. The die example is pretty simple, so using random variables may be a bit overkill, but let’s keep examples simple for now.

For a given experiment, we consider a variable, called X, and look at all the values it can reach with the associated probability. If my experiment is “rolling a die and looking at its value”, I can define a random variable on the value of a 6-sided die and call it X. For a full definition of X, I need to provide all the possible values of X (what we call the random variable’s domain) and their associated probabilities. For a 6-sided die, the values are the numbers from 1 to 6; for a non-loaded die, the probabilities are all equal to \displaystyle \frac 1 6. We can write that as follows:

\displaystyle \forall i \in \{1,2,3,4,5,6\}, \Pr[X = i] = \frac 1 6

and read “for all i in the set of values {1,2,3,4,5,6}, the probability that X takes the value i equals \displaystyle \frac 1 6.

One of the basic ways to have an idea about the behaviour of a random variable is to look at its expectation. The expectation of a random variable can be seen as its average value, or as “suppose I roll my die 10000 times, and I average all the results (summing all the results and dividing by 10000), what result would I typically get?”

This expectation (written E[X]) can be computed with the following formula:

E[X] = \displaystyle \sum_{i \in \text{dom}(X)} \Pr[x = i] \times i

which can be read as “sum for all elements i in the domain of X of the probability that X takes the value i, times i. In the die example, since the domain is all the integer numbers from 1 to 6, I can write

\displaystyle \sum_{i=1}^6 \Pr[X = i] \times i

which I can in turn expand as follows:

\begin{aligned}E[X] &=& 1 \times \Pr[X = 1] + 2 \times \Pr[X = 2] + 3 \times \Pr[X = 3]  \\ &+& 4 \times \Pr[X = 4] + 5 \times \Pr[X = 5] + 6 \times \Pr[X = 6]\end{aligned}

Since, for my die, all the probabilities are equal to \displaystyle \frac 1 6, I can conclude with

\displaystyle E[X] = \frac 1 6 \times (1 + 2+3+4+5+6) = \frac{21}{6} = 3.5

So the average value of a die over a large number of experiments is 3.5, as most tabletop gamers would know 😉

Now let’s look at a slightly more complicated example. Suppose that I have n dice, and that I want to know how many 6s I can expect in my n dice. From a handwavy point of view, we know that we will not get an exact answer for every time we roll n dice, but that we can get a rough answer. There’s no reason there should be more or less 6s than 1s, 2s, 3s, 4s or 5s, so generally speaking the dice should be distributed approximately equally in the 6 numbers, so there should be approximately \displaystyle \frac n 6 6s over n dice. (The exception to that being me playing Orks in Warhammer 40k, in which case the expected number is approximately 3 6s over 140 dice.) Let us prove that intuition properly.

I define Y as the random variable representing the number of 6s over n dice. The domain of Y is all the numbers from 0 to n. It’s possible to compute the probability to have, for example, exactly 3 6s over n dice, and even to get a general formula for k dice, but I’m way too lazy to compute all that and sum over n and so on. So let’s be clever.

There’s a very neat trick called linearity of expectation that says that the expectation of the sum of several random variables is equal to the sum of the expectations of said random variables, which we write

E[A + B] = E[A] + E[B]

This is true for all random variables A and B. Beware, though: it’s only true in general for the addition. We cannot say in general that E[A \times B] = E[A] \times E[B]: that’s in particular true if the variables are independent, but it’s not true in general.

Now we’re going to define n variables, called Y_1, Y_2, ..., Y_n so that Y is the sum of all these variables. We can define, for each variable Y_1, the domain {0,1}, and we say that Y_1 is equal to 1 if and only if the die number 1 shows a 6. The other variables Y_i are defined similarly, one for each die. Since I have n variables, which take value 1 when their associated die shows a 6, I can write

\displaystyle Y = \sum_{i = 1}^n Y_i

This is where I use linearity of expectation:

\displaystyle E[Y] = E\left[\sum_{i=1}^n Y_i\right] = \sum_{i=1}^n E[Y_i]

The main trick here is that variables Y_i are much simpler to deal with than Y. With probability \displaystyle \frac 1 6, they take value 1; with probability \displaystyle \frac 5 6, they take value 0. Consequently, the expectation of Y_i is also much easier to compute:

\displaystyle E[Y_i] = 1 \times \frac 1 6 + 0 \times \frac 5 6 = \frac 1 6

Plugging that in the previous result, we get the expectation of Y:

\displaystyle E[Y] = E\left[\sum_{i=1}^n Y_i\right] = \sum_{i=1}^n E[Y_i] = \sum_{i=1}^n \frac 1 6 = \frac n 6

which is the result we expected.

Now my examples are pretty simple. But we can use that kind of tools in much more complicated situations. And there’s a fair amount of other tools that allow to estimate things around random variables, and to have a fairly good idea of what’s happening… even if we involve dice in the process.

52Frames – 2019 Week 06 – Your Desk!

The theme for last week’s 52Frames was “Your Desk!“.

My first idea for the theme was to go for a very literal interpretation of the theme – I have made pictures of my desk in the past, mostly as “before/after” from my usual messy desk to a desk that stays way too ephemerally clean.

Instead, I used my new-ish journaling habit as a source of photographic inspiration: that’s my journal, my color pencils to color “trackers”, my pens to actually write things (I’m a bit in love with the Sign on the right, although it’s maybe a bit thick for my page size), and some brush pens for titles and decoration.

My goal there was to get as close as possible to “that picture makes my brain tingle in a nice way”: turns out, it’s incredibly difficult to achieve perfectly with round pens that tend to roll >_< Maybe I should have called some blu-tack to the rescue.

It must be said that the previous version of this picture was less brain-tingly: the pencils and brush pens were not in the same color order, and the crop was less satisfying. The friend to whom I had shown the first version of the picture noticed the color discrepancy (which was due to a re-ordering of pens according to numbers but not aligning the pencils order :P), so I re-shot and decided for another crop.

Also, I got to use my tripod in horizontal mode, which is always fun 😛

(And yes, the attentive reader will have noticed that this is indeed my gaming table and not my desk. Does that mean I cheated? I think I’m fine 🙂 )

Some more Marzipan bitmap fun

I did track down my zoom/scaling issue that I was mentioning in the previous post, and I improved the distance map for my bitmap orbit coloring. I’m still not 100% happy with it – I need to think a bit more about what I want to do there exactly, but it’s still enough that I spent a couple of hours yesterday playing with Marzipan as a “fractal generating software” and having fun with it, and not only as a “software project I’m working on”. Granted, the “UI” is still mostly “let me change the color palette and recompile”, but I was having too much fun making pretty images to dig into making the UI usable 🙂

So – here are a few pictures from my last “creative” session 🙂

Purple explosion

For “Purple explosion,” the seed bitmap is a bunch of rectangles of the same size put randomly on the canvas.

Rainbow equation

“Rainbow equation” is dedicated to Matthias, who was the one mentioning I should put the set equation in the image. And it’s rainbow because why the hell not 🙂

Lace flowers

“Lace flowers” uses one of the brushes from GIMP (Manju’s Flower – Large) as its base. I quite like this one, except for the fact that my processing of the flower should be smoother so that the end result is also smoother. That’s how I learn 😉

Tux funnel

For “Tux funnel”, I used as a base the Tux Mono drawing by gg3po, Iwan Gabovitch, GPL licensed, via Wikimedia Commons.

One of the things that amuses me is the ephemeral quality of what I do here. Choosing to save a picture (and that’s still somewhat of an ordeal) is the only way to keep a trace of what I’m doing. I cannot get back to an image and try to “keep it, but improve it”: since I don’t have my settings and I don’t remember where I zoom, any new attempt will be a new image. I even didn’t keep my seed bitmaps so far – so reproducing an image would really be hopeless. And I quite like it that way.

Marzipan – bitmap orbits (and some bugs)

I worked a bit on Marzipan this week-end, and started playing with bitmap orbits. The idea is the same as for point orbits and line orbits: we look at the iterations of the escaping points, and we look at the distance on the plane between the complex numbers represented by these iterations and a given set on the same plane.

Since my creativity was apparently all used up by trying to make the algorithm work instead of trying to find a nice bitmap to play with, I simply have the name of my project somewhere on an image, as black&white. I pre-compute a distance map to that bitmap (in a very approximate and most probably buggy way right now – something’s not quite right there, but good enough for a first approximation) and I use that distance map to display the points I’m interested in when rendering the fractal.

The very annoying thing is that I do have a bug on the zooming algorithm – things tend to flip and/or to go to weird places. I haven’t been able to track it down yet: it must be said that I’m typically hopeless at handling 2D grids and scaling factors without breaking a neuron or two, and that on top of that, as mentioned previously, I’m probably making my own life miserable by using a non-standard window manager. I’ll probably need to go to KDE or something to debug this thing properly (sigh :/)

Still, in the meantime, I’m not unhappy with the results 🙂