An Impeccable Spy: Richard Sorge, Stalin’s Master Agent

Owen Matthews (2019)

A biography of a much-romanticised Russian spy. Sorge spied on Japan while working for the Nazis while working for the Soviets. His fame rests on his determination of the date of Pearl Harbour (which Stalin didn’t pass on to the Americans), and his confirmation that Japan would not attack the Russian East (which Stalin was slow to believe) that allowed the Red Army to transfer a huge number of troops to fight and defeat the Wehrmacht at the gates of Stalingrad: one of the battles that decisively determined the outcome of the Second World War.

He was clearly a complex and troubled man, as many spies are. His cover as a hard-drinking womaniser wasn’t much of an act, and he spent Moscow’s money freely to keep in character. But he was also very badly served by his handlers, routinely disbelieved and threatened with the Stalinist purges, and sent a succession of inept collaborators. His commitment to Communism was sufficient to ride-out these challenges.

I would have liked to have read more about his “afterlife” in press and politics: it’s only covered briefly here, but there’s clearly a lot to be learned from his later rehabilitation and promotion as a Soviet idealist.

4/5. Finished Saturday 4 January, 2025.

(Originally published on Goodreads.)

New release of epydemic

New release of epydemic

It’s been a while – about 15 months since v.1.13.1 – but today I finally released v.1.14.1 of epydemic, a library for epidemic (and) other simulation over complex networks.

This release include several bug-fixes and two major changes.

Better Newman-Ziff percolation

The Newman-Ziff algorithm for bond and site percolation is widely used. The version that’s been in epydemic for a while emphasise speed over everything. However, in the course of some work by one of my MSc students on how grids of different dimensions respond to random failure, we discovered that we needed to be able to do some more flexible operations. In particular, we wanted to sample things other than just the size of the largest connected component, and wanted to be able to dig into to exactly how the network was deforming.

The problem was that this information wasn’t readily available. It was encoded within the algorithm’s data structure, but it wasn’t being reflected as an evolving network that was easy to get at. So we upgraded the algorithm to build a working copy of the network as it was constructed, so that it could be interrogated by normal networkx operations within the sampling process. This adds some time penalty, but it’s acceptable slowdown for the extra capability.

Multiple process instances

epydemic defines different epidemic processes (and indeed non-disease processes like pulse-coupled oscillators). Until now these have been usable alone in a simulation, but not together: one couldn’t run two diseases in the same simulation over the same population simultaneously. Doing so is obviously very desirable, especially if you want to explore co-infecting diseases.

Co-infection is a difficult problem. As a first step we’ve added multiple process instances which can have their own parameters and results – or can share parameters if required. This involves assigning distinct names to each instance, and then optionally using them to decorate parameter/result names.

This is fiddly if done manually, so we also added some methods on the Process class to get and set parameters and results using any instance name on the calling process. For example:

   params = dict()

   # network
   N = 10000
   kmean = 100
   params[ERNetwork.N] = N
   params[ERNetwork.KMEAN] = kmean

   # first infection
   p1 = SIR("Disease1")
   p1.setParameters(params,
                        {SIR.P_INFECT: 0.1,
                         SIR.P_INFECTED: 5.0 / N
                         })

   # second infection
   p2 = SIR("Disease2")
   p2.setParameters(params,
                        {SIR.P_INFECT: 0.3,
                         SIR.P_INFECTED: 5.0 / N
                         })

   # common removal rate
   params[SIR.P_REMOVE] = 0.005

   # run the processes together
   ps = ProcessSequence([p1, p2])
   e = StochasticDynamics(ps, ERNetwork())
   rc = e.set(params).run(fatal=True)

The setParameters call sets the parameters decorated with the name of the process, if it has one. There are other operations for extracting the parameters, and for interacting with experimental results without getting into the details of decoration.

See the project documentation for more details, as well as an updated tutorial and a cookbook recipe for co-infection (which is based around the code above). The Github repo is also available. To upgrade, just run:

   pip install --upgrade epydemic

or delete and re-build any virtual environments.

Lisp as a second language

Lisp as a second language

Peter Desain. Lisp as a Second Language: Functional Aspects. Perspectives on New Music 20, pp.192–222. 1990.

In some ways this article should come under “applications”, as it’s mainly concerned with using Lisp to represent and manipulate music. Indeed, it presents a system that can be used to perform all sorts of common transformations of the tones and timing of a piece. It’s easy to see how the resulting system could be used to compose and then to drive instruments, for example through a MIDI interface.

The music perspective is however secondary to the goal of teaching and showcasing Lisp through the medium of a realistic example of symbolic programming. It covers a lot of ground, starting with lists and functions and including first-class functions and combinators as means of implementing the musical structures. It’s a great piece of pedagogy that treats the application and the language as closely linked, and not shying-away from some quite advanced techniques that have clear applications in the domain. It would be great to see this used as a basis for actual musical composition and performance.

The Fund: Ray Dalio, Bridgewater Associates, and the Unraveling of a Wall Street Legend

Rob Copeland (2023)

Ray Dalio has always been a somewhat divisive figure in finance. He’s been a remarkably successful fund manager who rose from nothing to head an enormously powerful and innovative group.

But like many successful businessmen, Dalio seemed unable to rest on that success. He developed “the rules” as a template for his success, and within Bridgewater insisted that they form part of everyone’s mindset. He supplemented this with public shamings of a style that can only be likened to the “struggle sessions” of the Cultiral Revolution, with the target being required to confess their wrongdoings and promise improvement – often as a direct precursor to being demoted or fired. But of course the “rules” were infinitely malleable to match Dalio’s own needs of the moment, making them a tool of control rather than any kind of proper guide to conduct.

A lot of this was public knowledge, but forgiven by investors and collaborator because of the returns that Bridgewater generated. That’s a recurring theme in finance, for example as recounted in No One Would Listen, and encourages a culture of impunity when accompanied by profits.

4/5. Finished Sunday 10 November, 2024.

(Originally published on Goodreads.)

These Truths: A History of the United States

Jill Lepore (2018)

A history of the United States from its founding until the present day.

Lepore is a modern historian, and it shows: the 20th century gets most of the attention, with the Civil War being relatively under-described. But the coverage that there is is deeply researched and very satisfying. She spends time tracing the various currents that went into the writing of the Constitution and the ways in which the first years of the Republic both validated and refuted the concerns of the Framers – who had all agreed not to reveal what happened behind the closed doors of the drafting convention, which must have been deeply frustrating for those proved right.

The book is probably strongest when discussing social struggles. Slavery and the traditional civil rights era are dealt with in detail, as are the votes-for-women and the (unsuccessful) campaign for an equal rights amendment: the consequences of the latter failure have been severe, and sit at the core of current illiberal trends in the US politics.

4/5. Finished Friday 8 November, 2024.

(Originally published on Goodreads.)