The 2D XY model has played a pivotal role in physics of the past half-century. The model describes a collection of interacting rotors or spins are free to rotate in the xy-plane. Each spin is associated with a site on a square lattice and is described it’s angle parameter . Spins interact with their four nearest neighbours . The *energy* of a particular configuration is

(1)

The negative sign in Eqn (1) implies that parallel arrangements of spins have lowest energy (“ferromagnet”). The likelihood of a configuration is given by the Boltzmann distribution of statistical physics. With uniform priors[*] the posterior joint probability distribution is

(2)

where is the inverse temperature.

In statistical physics the number of internal parameters can be very large (e.g. Avogadro’s number for a 2D system ). On the other hand is the sole external data value. This is an extreme limit of Bayesian inference where the inference dataset is small but there are an enormous number of model parameters. In statistical physics, interesting posterior distributions arise from the explicit interactions between parameters even in the absence of a rich inference dataset.

The statistical physics of the 2-D XY model is far from trivial. When spins align in some direction to minimise the energy [**]. For large but finite spins are nearly parallel and the cosine terms in Eqn (1) can be expanded as a quadratic in the small angular differences between neighbouring spins. This “spin-wave” model can be solved analytically. For large it gives “quasi long range order” i.e. power law decay of spin correlations with distance with exponent .

In the opposite weak coupling limit entropy dominates and typical draws from the posterior distribution consist of nearly randomly oriented spins and short range (exponentially decaying) correlations. This suggests that a phase transition exists between a weak coupling disordered phase and a strong coupling phase with quasi long range order. The transition is known to occur at for very large . As the transition is approached from below .

It is a remarkable fact that the phase transition in the 2D XY model is driven by a proliferation of vortices (topological defects). This discovery was made in the 1970s and awarded a Nobel prize in 2016. Some vortex configurations on an ordered background are illustrated below. Note that the spins return to their undisturbed state far from a vortex anti-vortex pair but not in the other cases shown. [***]

It is an easy task to simulate Equations (1) & (2) in *stan*. The *stan* code (uniform priors and periodic boundary conditions) is

xy_model <- ' functions{ //function f to impose periodic boundary condition int f(int i, int L){ if (i == 0) return L; else if (i == L+1) return 1; else return i; } } data { int D; //dimension of square lattice real beta; //coupling or inverse temperature } parameters { matrix<lower=-pi(),upper=pi()>[D,D] theta; //the spin parameters } model { //the site energy matrix[D,D] energy; for(i in 1:D) for(j in 1:D) energy[i,j] = cos(theta[f(i+1,D),f(j,D)]-theta[f(i,D),f(j,D)]) + cos(theta[f(i-1,D),f(j,D)]-theta[f(i,D),f(j,D)]) + cos(theta[f(i,D),f(j+1,D)]-theta[f(i,D),f(j,D)]) + cos(theta[f(i,D),f(j-1,D)]-theta[f(i,D),f(j,D)]); for(i in 1:D) for(j in 1:D) { target += exponential_lpdf(4-energy[i,j]| beta); } } '

To run the model in R,

library(rstan) xy_mod <- stan_model(model_code = xy_code) Nchain <- 8 D <- 32 init <- lapply(1:Nchain, function(i) list(theta=matrix(runif(1,-pi,pi),D,D))) #random orientations xy_samples <- sampling(xy_mod,chains=Nchain,init=init, data = list(D=D,beta=0.9), iter = 2000, warmup=1000)

Here are some posterior draws generated by the above code after warm-up for ().

Firstly, low-temperature “spin-wave” phase with power law correlations…

Secondly, the high temperature disordered phase with unbound vortices …

Finally, close to the transition, weakly bound vortex-ant-vortex pairs…

It is straightforward to compute quantities of physical interest from the HMC sample draws. The graph below shows mean energy per site, mean site magnetisation and mean square vorticity averaged over ~ 10,000 draws. Vortices proliferate in the vicinity of the transition as expected.

[*]Non-uniform priors can also be used in Eqn. (2). A simple choice is the circular Von Mises distribution

which favours spin direction . This is mathematically identical to uniform prior and an external “magnetic field” () term in Eqn. (1) with .

[**] A very small external magnetic field can be used to select the direction.

[***] Net vorticity of a region is measured by summing angular differences around it’s perimeter , (where each angular difference is wrapped to the interval . ) This formula can be applied to an individual plaquette to locate vortex cores, for example.

]]>Unlike the *bits* of digital computing, *qubit* states of a quantum computing (QC) can be rotated continuously (by probability-preserving unitary transformations). A typical quantum algorithm runs in three steps: *(1)* a register of qubits is prepared in some known initial state *(2)* qubits are manipulated through a sequence of physical operations (corresponding to unitary transformations on multi-qubit states) *(3)* a probabilistic snapshot of the final quantum state is extracted (measurement). The algorithm runs in step *(2). S*tep *(3)* is the read-out of results.

The list of elementary examples of QC is a short one. However, a quantum experiment often involves the same three steps above*, *and the result of the experiment always “computes” some quantity*.* Any quantum experiment has a QC interpretation.

Here I describe the quantum mechanics of indistinguishable photons entering a *beam-splitter*. A pair of glass prisms glued together with a thin layer of resin form a device which partly reflects and partly transmits a beam of light. In classical optics a beam-splitter is described by complex transmission (,) and reflection (,) amplitudes that account for phase shifts of beams approaching from the left and right (unprimed and primed respectively). These amplitudes form a unitary matrix which has the general form

It turns out that all of the results discussed here are independent of phases and . For definiteness choose and . Then

If the angle , . This is called “the standard 50:50 beamsplitter”. Here I allow to be different from .

The unitary matrix of classical optics carries over to the quantum case. Suppose that photons arrive at the beam splitter from orthogonal left or right channels as in Fig 1. The two orthogonal states are qubits denoted and . If a photo passes through the beam-splitter from the left, the photon state is rotated to . A photon in right channel is rotated to The transition amplitudes are and . According to the rules of quantum mechanics the probability that a photon which entered from the left is detected in the left channel is the square modulus of the transition amplitude . The probability of finding the photon in right channel is. If the probability is 50:50 as expected.

Fig 1

When photons are present, it is best to use many-photon *Fock state *notation. denotes a state with photons entering in the left channel and photons in the right channel (for example, the single photon state above would be represented by ). In general the beam-splitter transforms an initial Fock state into an entangled Fock state . In general this is a superposition of all possible states with photons in left and right channels (satisfying ) . Of course measurement (i.e. photon counting) will yield definite values , . In the language of QM, measurement is said to “collapse” the state. However, by repeating the experiment many times, the full probability distribution can be found.

It is straightforward to calculate the general form of the beam-splitter transition amplitude (the quantum mechanical calculation takes the indistinguishable boson nature of photons into account. For details with see reference **[1]** below). The answer is:

(1)

Suppose that all photons enter in the same channel. In this case only a single term () survives in the sum in expression (1). The amplitude is . The square modulus of this amplitude can easily be recognised as just the binomial distribution with playing the role of probability. In this case the beam-splitter is analogous to a classical analog computer, the Galton Board.

Even though the computational details look very different, this is once again the expected result from classical probability.

What happens if photons enter in both left and right channels? Suppose that one photon enters each channel. Two terms survive in expression (1) but with opposite sign and the amplitude . This vanishes for a 50:50 beam-splitter. In other words the photons enter separately but always leave together. This effect, which appears to contradict intuition based on classical probability theory, is the experimentally observed Hong-Ou-Mandel effect in quantum optics. Generalising to the case where photons enter on the left and a single photon enters on the right, once again only two terms survive in expression (1) and , and the probability distribution is:

where . This is very different from the binomial distribution because it is bimodal. For example, for and even , it vanishes when which is where the binomial has its maximum. This is true even when .

What about the general case? The probability of observing photons in the left channel given that photons enter the left channel () are shown below for a 200-qubit beamsplitter and :

Another representation of the probability distribution () is shown below:

The -photon beam-splitter experiment illustrates the preparation, transformation, measurement steps of QC and “computes” the square modulus of expression (1). Note that the factorials appearing in expression (1) are problematic on a classical computer when without resorting to Stirling’s approximation.

Generalisations of the beam-splitter experiment to the multi-channel case known as Boson Sampling **[2]** have been proposed as a means to demonstrate *quantum advantage,* a computation that can be executed in QC but is infeasible on a classical computer. The quantity computed in Boson Sampling is closely related to the permanent of a matrix, a computationally hard problem on a classical computer.

]]>

Salekhard (66.53 °N, 66.67 °E) is located in Yamalia at the Northern end of the Ural mountain range. 95% of the daily average temperatures observed at Salekhard weather station since 1882 fall within the shaded area of the above graph. The red line at 5°C is an indicative lower threshold for plant growth. Clearly, the growing season in Yamalia is temperature limited, variable and short.

Tree ring data have been collected from specimens of living and sub-fossil larch trees (*Larix Sibirica*) found in the vicinity. This is known as the *Polar Ural* dataset. Specialists have created growth index chronologies extending back over more than a thousand years, allowing inferences to be made about local climatic history. The data confirm that annual tree growth is correlated with “summer temperature” (usually taken as the average of June-July-August). The Polar Ural dataset includes X-ray measurements of annual maximum latewood density (MXD). It turns out that MXD is more strongly correlated with temperature than are noisier tree ring widths, making the Polar Ural data an especially useful tree ring thermometer.

Plants have a more complex response to temperature than does, say, a mercury thermometer. In horticulture daily growth is usually taken to be zero below a base temperature threshold and linear above. However this response is unlikely to be uniform over the growing season. Indeed for most plant species, warmth is more beneficial in the early “vegetative” part of the growing season than in late summer or autumn. Putting these facts together, I assume that annual tree growth is sensitive to an *effective growing season temperature* defined by

(1)

where is temperature on day and is an interval of days which spans the growing season (e.g. for Polar Urals I took from 11 Apr to 27 Oct). Daily weights () can be modelled flexibly using a two parameter function (defined on the interval [0,1]):

(2)

and produces a centrally peaked distribution, while controls the degree of asymmetry. Positive values of give a higher weight to earlier parts of the growing season and visa versa.

Although wood density is expected to increase with , it cannot exceed some physical limit, implying an additional non-linearity in the relationship between and MXD growth index. A simple model of expected MXD is:

(3)

For the same reason, errors about expected MXD are skewed to the downside. I assume a skew-Normal distribution:

(4)

For zero skew () this reduces to a standard normal distribution with mean and standard deviation .

With suitable priors, joint posterior probability distributions for the 7 parameters of Equation 1-4 were obtained using the remarkable Markov Chain Hamiltonian Monte Carlo package *stan.*

For *stan* aficionados, the calculation used 4 chains each with 1000 iterations of which 500 were warmup. All values of 1.01 suggesting good convergence. The fit to MXD data is illustrated below using mean values of the parameters (showing 5% and 50% confidence intervals of the skew Normal error distribution).

A few more things.

- The posterior distribution of and can be used to estimate the point in the growing season where growth is most sensitive to temperature. This turns out to be 27 June 17 days. As expected, this is in the earlier part of the growing season.
- Prior and posterior distributions of are shown in the graph below. is quite well constrained by the data at biologically reasonable values i.e. within the range expected for a cold weather plant species.
- The posterior “summer temperature” determined by Bayesian analysis is similar but not identical to the standard JJA summer temperature often used by specialists to reconstruct of past climates close to the tree-line in the Northern Hemisphere. The relationship is illustrated below using mean posterior parameters values.

In a follow up post I will look at the calibration problem of reconstructing from observed .

]]>

- Chromaticity diagrams represent all colours that can be perceived by the human eye. The L
*uv*colour space (“CIE 1976”, illustrated above at a particular luminosity L) is believed to be approximately “perceptually uniform” which means that the distance between any two colour points is proportional to the colour difference perceived by humans. - The colours of the rainbow (spectrum of visible light) correspond to saturated colours on the curved boundary of the
*uv*-diagram. These monochromatic colours (indicated above at 20nm intervals) are not distributed uniformly in*uv*space. In other words the*colour acuity*of the human eye depends on wavelength. There is a strong peak at 484nm (cyan) and another broader peak at 592nm (orange).

- The colours of the rainbow are shown below, firstly as a linear function of wavelength and secondly in perceptually uniform space. Notice that the cyan, blue-green and orange areas expand, while green, red and violet shrink.

- Digital photographers are familiar with tristimulus sRGB, Adobe RGB and proPhoto colour triangles. In
*uv*space, these cover 33%, 39% and 77% of perceivable colours respectively. Of course, colours outside the sRGB gamut cannot be displayed correctly on any sRGB device. In particular, strictly speaking none of the colours of the rainbow are displayed correctly in sRGB (or ARGB). - Assuming that it is perceptually uniform, the
*uv-*diagram can be used to compute the*colour error*for the visible light spectrum*.*ARGB reduces the colour error at all wavelengths relative to sRGB, because the sRGB gamut is a subset of the ARGB gamut. However there is still a significant error at the 484nm colour acuity peak. proPhoto has the nice property that the colour error is zero in the vicinity of the cyan and orange colour acuity peaks. Unfortunately no proPhoto displays exist at the present time. - There is an excellent discussion of the difficulties in rendering the visible light spectrum here.

Computations were done using R’s *colorscience* and *rgeos* packages.

]]>

..*large eruptions in the tropics and high latitudes were primary drivers of interannual-to-decadal temperature variability in the Northern Hemisphere during the past 2,500 years. Overall, cooling was proportional to the magnitude of volcanic forcing and persisted for up to ten years after some of the largest eruptive episodes. Our revised timescale now firmly implicates volcanic eruptions as catalysts in the major century pandemics, famines, and socioeconomic disruptions in Eurasia and Mesoamerica*..[1]

- a large volcanic eruption injects tens of millions of tons of sulphur dioxide into the stratosphere, causing global or hemispheric dimming. The cooling effect may last for several years.
- the box-and-whisker graph above shows distributions of the annual growth of trees at two subarctic (taiga) forest sites in Quebec and Russia and at a subalpine forest in France, from 1300 to the present day. These sites are close to the tree line where temperature is likely to have been the limiting factor for growth. The graph suggests that volcanic cooling had a significant impact on forest growth.
- tree ring chronologies for each site were created by detrending raw data from individual trees and averaging. While this procedure loses information about climatic shifts lasting longer than a few decades, shorter term variability (for example, from volcanoes) is retained.
- sulfur deposition in Antarctic ice cores was taken as the measure of volcanic aerosols. A simple annual average from 21 carefully dated Antarctic ices cores was taken
*[1]*. To allow for the fact that aerosol effects can last for more than one year, an exponentially weighted moving average with decay constant of 3 years was computed. Years in which this average exceeded a threshold (40ng/g) were deemed “volcanic”. There were 30 such years since 1300, an average of 4 per century. Interestingly there have been no such years since 1821. - the list of “volcanic” years according to the above criterion since 1300 are: 1347 1459 1460 1461 1462 1463 1464 1465 1466 1600 1601 1602 1603 1604 1643 1644 1696 1697 1698 1810 1811 1812 1813 1815 1816 1817 1818 1819 1820 1821. Most of these correspond to years following well-known historical eruptions such as Kuwae 1453, Huaynaputina 1600, Tambora 1815 and the mystery 1809 volcano.
- strangely, the impact of volcanoes appears weaker if Greenland ice core data is used instead of Antarctic data. Furthermore, the relation between tree-ring and ice core data appears much weaker in the pre-1300 data. For example, there is little evidence of the very large 1257 Samalas eruption in the growth indices at the sites selected (below).

Tree ring indices were calculated from raw research data (.rwl files) archived by NOAA paleoclimate. For example, the Quebec l1 data is available here:

https://www1.ncdc.noaa.gov/pub/data/paleo/treering/measurements/northamerica/canada/cana458.rwl

Growth index chronologies were calculated in R using the dendrochronology *dplR* package. Simple negative exponential detrending was used, which attempts to capture mean biological growth rates over the life of a tree (typically conifer ~ 100 years). For example, the raw Quebec l1 site index chronology (Gennaretti *et al* ) was calculated as follows:

library(dplR) l1 <- read.rwl("https://www1.ncdc.noaa.gov/pub/data/paleo/treering/measurements/northamerica/canada/cana458.rwl") l1.rwi <- detrend(rwl = l1, method = "ModNegExp") l1.crn <- chron(l1.rwi, prefix = "QUE") ...

Antarctic sulfate ice core data described in Sigl et al are available in this spreadsheet.

** [1] Timing and climate forcing of volcanic eruptions for the past 2,500 years.** Sigl, M., Winstrup, M., McConnell, J. R., Welten, K. C., Plunkett, G., Ludlow, F., … Woodruff, T. E. (2015). Nature, 523(7562), 543–549. DOI: 10.1038/nature14565

An AC power network consists of “buses” (vertices or nodes) and “transmission lines” (edges or links). Buses are of two types – “generators” (power sources) and “loads” (power sinks). To a good approximation, power flowing along a link from node i to node j in a high voltage AC transmission network is given by

(1)

where is the voltage phase at node and is the capacity of the transmission line linking and . Maximum power flows when the phase difference is 90.

The capacity of the transmission network as a whole is the maximum total power consumption that it allows. Assume for simplicity that all transmission lines have the same capacity and that all generators and all loads are identical. This simplification means that, if there are generators and cities, each generator produces power and each load consumes power . Given a network topology and , the set of ‘s which satisfy Equation 1 can easily be found, at least for smaller networks. Eventually, when is increased to a critical value, no solution is possible. The capacity of the network has been reached.

Figure 1 shows a 5-node 3-generator 5-link network operating at it’s critical capacity. Each generator produces power and each load consumes 1.5. Power flows are indicated in red, with arrows on links giving the directions of flow. Node arrows indicate phase angles. Note the 30 phase difference between generators A and B and between the cities.

Suppose that a new link is added between A & B, coupling the phases of these two generators. The large phase angle between A & B of Figure 1 produces a current which cannot be sustained without disrupting the phases on all of the other nodes.

The new critical state with phases reorganised to maximise capacity in the new network is shown in Figure 2. Generators A & B are now nearly in phase, with only a small current flowing between them. The capacity of the network is reduced to 2.91, 3 lower than the less connected network of Figure 1.

A more extreme case is shown below, where adding an additional three links to a simple power network degrades the capacity of the network by .

Calculations using ** R**‘s excellent

[1] *Braess’s paradox in oscillator networks, desynchronization and power outage*, D. Witthaut and M. Timme, 2012.

]]>

- The graph shows annual median speed of ships from 1750 to 2014. It is based on historical location data from 617,754 vessels in the ICOADS dataset.
- Ship speeds increased by 0.2kn/decade up to 1880. This reflects incremental improvements in sailing ship technology, which reached a peak with
*Sovereign of the Seas*(1852, capable of 22kn). - The impact of new technologies such as steam paddle ships (
*SS Sirius,*1837), steel hulls and screw propellors (*RMS Oceanic,*1871) is not evident until the late 1800s. Then, between 1881 and 1905, median speed of ships increased at an astonishing rate ~ 3kn/decade, a near step change compared to the past. The ocean liner*SS City of Paris (*1889*)*had a cruising speed of 20kn. - From 1906 to 2014, speeds increased at a modest 0.3kn/decade on average, comparable to the rate during the sail ship era.
- A striking feature of the graph is that the median speed of ships is much more variable in the modern era compared to 18th and 19th centuries. Political and economic factors, rather than technology, became dominant driving forces e.g. oil supply and financial crises. A dramatic example is the sharp decline in speed of ships at the end of 2008 following the collapse of the Lehman Brothers.

Ship trajectories from ICOADS were stored in a dataframe *ships** *with ~100 million rows.

Median speeds were calculated using *dplyr*

library(dplyr) library(geosphere) ships <- arrange(ships,ID,time) ships <- ships %>% group_by(ID) %>% mutate(dx = distGeo(cbind(lag(LON),lag(LAT)),cbind(LON,LAT))/1000,dt = as.numeric(difftime(time,lag(time),units="hours"))) shipsdx/ships$dt ships <- filter(ships, dx !=0 & dt <= 48) #data within consecutive days only ships <- arrange(testA,ID,time) shipspeeds <- ships %>% group_by(ID,year) %>% summarise(distance = sum(dx,na.rm=T),speed = median(V,na.rm=T))

The speed of a vessel was calculated whenever it’s location coordinates were available within consecutive days in ICOADS dataset.Periods of zero speed (ship docked or at anchor) were omitted. Buoy and drifter data were excluded. Insufficient data was available for the years 1864-87.

]]>

- The graph shows a comparison between modern sea surface temperatures (SST) and temperatures measured during the 1831-1836 voyage of Captain Fitzroy and Charles Darwin on HMS Beagle.
- Data collected by the Beagle were assigned to weekly buckets of a 53-week year. Modern (1981-2017) weekly means at the ship locations were subtracted to give temperature “anomalies” experienced during the voyage.
- The graph indicates that the Eastern Pacific ocean was anomalously cold during Darwin’s time at the Galapagos (shaded area). This looks consistent with a La Nina event.
- Average temperatures during the voyage were 0.7°C cooler compared to an equivalent trip made today. The Beagle data are slightly more volatile compared to the modern SST dataset. This is to be expected because the latter is an average over time and space (1° x 1°) whereas the Beagle measurements were local in time and space.
- Measurements at anchor and at interpolated coordinates are omitted.
- HMS Beagle data derived from the ICOADS database, which is a very rich source of shipping data with all kinds of application.

]]>

On a recent trip, I visited *Campbell Island*, the Southern-most of New Zealand’s extraordinary sub-antarctic islands. A fellow visitor from Ireland pointed out that Campbell is the land mass furthest from home i.e. Campbell Island is the true Irish antipode. I had always assumed (wrongly) that this distinction was held by the eponymous *Antipodes Island*.

The situation is shown below. Black dots mark the centroids of the small sub-antarctic islands after reflection through the centre of the earth.

Colours show which dot is nearest, using geodesic distances on an ellipsoidal earth. This is just an ordinary Voronoi diagram, expect that the curvature of the Earth is taken into account accurately. (*distGeo*() function from *R*‘s *geosphere* package).

Campbell is the antipode for Ireland and Scotland, while Antipodes Island is antipode for England, Wales and Normandy (except for Anglesea and a sliver of Cumbria).

]]>The map shows tracks of drifting buoys deployed in the southern ocean between 2005 and 2016. The underlying dataset consists of 15-minute gps data collected from 4608 buoys, available from NOAA ftp://ftp.aoml.noaa.gov/pub/phod/buoydata/. Colour indicates speed of drift.

This is simply a visualisation of the raw drifter data with no further analysis or modelling. Nevertheless all of the well-known features of the surface circulation in the southern ocean emerge; Antarctic Circumpolar Drift, western boundary currents along the western coasts of South America (Brazil Current) and Africa (Agulhas), powerful Agulhas Return Current in the Southern Indian Ocean, South Atlantic gyre (centred NorthEast of the Falkland Islands) etc.

A dataframe *buoydata* was created using *fread(),*

library(data.table) buoydata <- fread("../buoydata_10001_15000.dat")

transformed to a stereographic coordinates using *spTransform()*

library(dplyr) library(sp) antarctic <- CRS("+proj=stere +datum=WGS84") lonlat <- CRS("+proj=longlat +datum=WGS84") buoydata.sp <- SpatialPointsDataFrame(select(buoydata, lon,lat),data = select(buoydata,-lon,-lat),proj4string=lonlat) buoy.df <- as.data.frame(spTransform(buoydata.sp,antarctic))

and plot using *geom_path()*

library(ggplot2) ggplot(buoy.df) + geom_path(aes(lon,lat,group=ID,colour=speed),alpha=0.15,size=0.2)

Note the use of transparency (alpha). This can be varied to highlight different aspects of the flow.

]]>