Fast generation of isotropic Gaussian random fields on the sphere

The efficient simulation of isotropic Gaussian random fields on the unit sphere is a task encountered frequently in numerical applications. A fast algorithm based on Markov properties and fast Fourier Transforms in 1d is presented that generates samples on an n x n grid in O(n^2 log n). Furthermore, an efficient method to set up the necessary conditional covariance matrices is derived and simulations demonstrate the performance of the algorithm. An open source implementation of the code has been made available at https://github.com/pec27/smerfs .


Introduction
Methods for modelling spatially distributed data with isotropic random fields occur in many areas, including astrophysics [2,8], geophysics [19], optics [12], image processing [4] and computer graphics [13].The building block for almost all of which is the Gaussian random field in R d , although many applications require realisations in other geometries, the most important of which may be the unit sphere, S 2 , especially for geophysics and astrophysics, which often use spherical data.
The computational complexity of realising an n × n lattice of points of a Gaussian random field in R d depends considerably upon the structure of the covariance function.In the worst (non-isotropic) case we must calculate the covariance between each point and perform a Cholesky decomposition of the resulting matrix, at a cost of O(n 6 ) operations [19].Fortunately, the majority of Gaussian random fields we are interested in are isotropic (i.e. the covariance depends only on the geodesic distance between points), allowing us to perform a spectral decomposition into harmonic (Fourier) components.In the periodic case on R 2 (i.e. a torus) with a regular lattice, this provides a dramatic computational improvement due to the existence of the fast Fourier transform (FFT) algorithm, which allows the realisation to be computed in O(n 2 log n 2 ) operations.
On S 2 , similar results for isotropic Gaussian random fields also apply, i.e., we can perform a spectral decomposition into the spherical harmonic functions.Unfortunately the corresponding spherical transform algorithm has fewer symmetries to exploit, and for a general n×n grid on the sphere, O(n 4 ) steps are required for an isotropic covariance function.If one chooses an iso-latitude system such as the equidistant cylindrical projection (i.e. a regular grid in θ and φ, the inclination and azimuthal angles) or the HEALPix discretisation ( [7], as used for the cosmic microwave background data of WMAP) one can exploit the Fourier element of the azimuthal angle to reduce this to O(n 3 log n) (see e.g.[6]).
As one moves to higher and higher resolutions, however, it becomes even more attractive to find algorithms with superior scaling.One such possibility is to consider Gaussian Markov random fields (hereafter GMRFs) (e.g.[23,11,16,21,14,22]) which extend the Markov property to higher dimensions and orders.The essential property of these fields is that the probability measure for a conditional realisation of these fields depends upon only the boundary of the constraining set (and its derivatives) rather than the full set.Such a property allows one to construct a realisation recursively, i.e. to iteratively expand the realisation around its boundary, a process sometimes described as a telescoping representation [22].
The requirement for an isotropic GMRF to obey this property is that the covariance function is the Green's function of an operator that is a polynomial in the Laplacian (with appropriate coefficients to ensure strong ellipticity, see e.g.[14]).This turns out to describe rather a large class of covariance functions [21].
The contribution of this paper is an algorithm that generates samples on an n × n grid of the sphere in O(n 2 log n) once the conditional covariance matrices are computed.This is achieved by decomposing the field into 1d Gaussian Markov random fields.These can be sampled together with the derivatives point by point and then transformed to an isotropic Gaussian random field on the unit sphere by FFT.
The paper is structured as follows: In Section 2 we derive the decomposition of an isotropic Gaussian random field into 1d GMRFs via Fourier transforms and compute the conditional covariance matrices.A computationally efficient method to set up the conditional covariance matrices is presented in Section 3. We collect the results of the previous sections in Section 4, where we present the algorithms explicitly.Finally, the performance and convergence of the introduced algorithm is demonstrated in a simulation example in Section 5. Our implementation is available online at https://github.com/pec27/smerfs.
(3) The elements of A + with m = 0 are real-valued and N (0, C ) distributed.(4) The elements of A with m < 0 are deduced from those of A + by the formulae Here (C , ∈ N 0 ) is called the angular power spectrum.
In what follows let us consider the case that there exist κ i ∈ C such that (1) for all ∈ N 0 , i.e.C −1 is an eigenvalue of with corresponding eigenfunctions (Y m , m = − , . . ., ), where ∆ S 2 denotes the spherical Laplacian (also known as the Laplace-Beltrami operator ).In the spirit of [10], T is the solution of the stochastic partial differential equation where W is white noise which admits the formal Karhunen-Loève expansion Here (η m , ∈ N, m = 1, . . ., ) is a set of independent, complex-valued standard normally distributed random variables independent of the real-valued standard normally distributed random variables (η 0 , ∈ N 0 ).For m < 0 the same relations as in Condition (4) hold.For fixed m ∈ Z, define the random field and obtain for any m 0 ∈ Z where we set Moreover, we obtain for m 0 < 0 the relation Since g m 0 is generated by a sum of centred Gaussian random variables, it is clear that g m 0 is centred Gaussian.In the following lemma, we show that they are independent for positive m and compute the covariance.
Lemma 2.1.The sequence (g m , m ∈ N 0 ) consists of pairwise independent centred Gaussian random fields on [−1, 1] with covariance given by while the functions (g m , m < 0) with negative index are determined by the relation Proof.We have already seen that g m is centred Gaussian and that g m = g −m .It remains to show independence as well as to compute the covariance.Therefore let us fix m 0 , m 1 ∈ Z and . By the previous computations it holds that using the properties of the random variables in A, where δ m 0 m 1 = 1 for m 0 = m 1 and 0 else.Similarly we obtain which finishes the proof, since uncorrelated Gaussian random variables are independent.
We define the operators Let us recall the associated Legendre differential equations for ∈ N 0 and m = − , . . ., (see, e.g., [1]) which is solved by the associated Legendre polynomials.Therefore we obtain that i.e. g m solves the stochastic differential equation m is a well-defined operator of order M since D m is of order 2M with positive spectrum.
For τ ∈ (−1, 1) let us first consider the open sets A τ = (τ, 1) with complements A c τ = (−1, τ ].Since white noise satisfies the strong Markov property, we obtain for all z ∈ A τ that and g m is generated by a stochastic differential equation as in [18,Eqn. (2.1.21)].However, g m does not satisfy it but it follows from [18] that the M -dimensional vector of derivatives up to order M − 1, M , . . ., g (M −1) m ) T have the property.In other words, we obtain for all z ∈ A τ P g (0...M −1) Therefore it is sufficient to know g m (τ ) for p = 0, . . ., M − 1 when generating a sample value for any z > τ where the random field is already constructed for all z < τ .Since we are considering Gaussian fields which have Gaussian derivatives, it is sufficient to know the mean and the covariance between any two points and derivatives up to order M − 1.
Since all derivatives are well-defined, we obtain the covariance functions, which we will refer to as cross covariances, These derivatives can analytically be calculated with the identities of the associated Legendre polynomials.We will discuss a computational efficient method in Section 3. Let us set J m pq (z 1 , z 2 ) := C gm,p,q (z 1 , z 2 ) such that J m (z 1 , z 2 ) is the matrix consisting of all covariances between different derivatives at z 1 and z 2 .The conditional distribution of g and conditional covariance matrix Using the values g (0...M −1) m (z 1 ) at z 1 for non-negative m, it is straightforward to sample the vector g (0...M −1) m (z 2 ) from the conditional distribution by ( 4) where the random variables (w m q , q = 0, . . ., M − 1) are independent complex-valued standard normally distributed for m > 0, and independent standard normally distributed for m = 0.This construction is sometimes referred to as a state-space model [3].
Note that we will also need an initial sampling, and for this we choose the equator (z = 0), i.e. (5) where B m eq (B m eq ) T := J m (0, 0).

Efficient covariance computation
We have shown in Lemma 2.1 that i.e. we obtained a representation in term of the associated Legendre polynomials.This allows us to compute it but from an algorithmic perspective, the computation is expensive for large m and as the recurrence relations are unsuitable for numerical computation with limited precision.As such we find an alternative formulation in terms of Legendre functions that is numerically superior at even moderate-m values.
Let us assume that the κ i are distinct in Eqn.(1) and have the representation κ i = −λ i (λ i + 1) with λ i ∈ C \ Z to avoid singularities.More specifically, for λ i ∈ Z, either = λ i or = −λ − 1 is in N 0 and therefore C is not well-defined.A typical example is M = 2 and C = (a 2 + 2 ( + 1) 2 ) −1 with a ∈ R, which satisfies the desired partial fraction decomposition with κ 1 = ia and κ 2 = −ia.Then the coefficients C in Eqn. ( 1) can be decomposed (via partial fractions) into ( 6) for some finite constants b i ∈ C, provided the κ i are distinct.
We note that the partial sums in Eqn. ( 3) can be written in the form where , which is nothing more than the bilinear expansion for the Green's function [17,Eqn. (17.72)] for the operator D m = κ i − L m .This operator can be alternatively formulated as the solution to the differential equation ( 7) One eigenfunction of this operator with eigenvalue zero is the associated Legendre function P m λ i , where P m λ i denotes the generalisation of P m to non-integers λ i .Associated Legendre polynomials can be generalised to complex degree λ and order µ as via the (Gauss) hypergeometric function where (x) n denotes the rising Pochhammer symbol.The relevant case of µ being an integer (i.e.µ = m) is only defined in the limit, which we find by (see [1, 15.3.3]) and (see [1, 15.1.2]) This function is well-defined at z = 1 with P m λ (1) = δ m0 and singular at z = −1 for all m ∈ N 0 if λ / ∈ Z.
For a second linearly independent solution to (7) we use P m λ i (−z), which is not linearly dependent since λ + m is not an integer, see, e.g.[1, 8.2.3].We can then construct the Green's function by using the Wronskian (e.g.[5, 14.2.3]) x ≤ y, P m λ (x)P m λ (−y), x ≥ y, which satisfies continuity, regularity at x = −1 and x = 1, and by substitution Substituting the associated Legendre functions by the hypergeometric functions as in (8), i.e. setting 1 − z 1 2 and similarly for q and z 2 , we derive our efficient computation method for the cross-covariance matrices J m .
We observe that the above formula requires many re-computations of associated Legendre functions.To be more efficient, we transform the vector g (0...M −1) m of derivatives up to order M − 1 to a vector of linear combinations of derivatives of increasing order.This does not change anything since we are in the end only interested in the random field itself but not in its derivatives.Therefore define for m ∈ N the family of operators (U q m , q = 0, . . ., M − 1) by y) is much easier to compute while the properties of the random field itself are not changed.Let us keep the notation g (0...M −1) m even if we use the modified matrices J m .

Algorithms
Below we outline an algorithm for the construction of the isotropic GRF on S 2 .Since the sampling of the GRF is merely filtered white noise, in our tests the time is dominated by the computation of the (inhomogeneous) filter coefficients, and as such we have described the pre-computation in Alg. 1 which just has to be done once and the generation of samples in Alg. 2.
For n ∈ N let us fix a grid z = (z −n , . . ., z 0 , . . ., z n ) on [−1, 1] and φ = (φ 0 , . . ., φ 2mmax ) for some m max ∈ N. One possible symmetric example is to set z j = sin 2πj 2n+1 , such that for m = 0, . . ., m max + M − 1 do Set up the hypergeometric functions 2 F 1 of order m using z and λ. for p = 0, . . ., M − 1 do Set up the Pochhammer symbols for m and p using λ.end for end for for m = 0, . . ., m max do Compute J m (z 0 , z 0 ) using ( 9) and the computed functions.Compute B m eq from J m (z 0 , z 0 ) (e.g. via Cholesky decomposition).for i = −n + 1, . . ., n do Compute J m (z i , z i ) using ( 9) or (10) and the computed functions.Compute J m (z i−1 , z i ) using ( 9) or (10) and the computed functions.Compute A m (z i−1 , z i ) using J m and (2).Compute B m (z i−1 , z i ) using J m , A m , (3) and, e.g.Cholesky decomposition.end for end for Return A = (A m , m = 0, . . ., m max ), B = (B m , m = 0, . . ., m max ), and B eq = (B m eq , m = 0, . . ., m max ).end procedure Alg. 1 is devoted to the pre-computations that set up the covariance matrices that just have to be computed once and can be reused for sampling on the same grid.We remark that the algorithm can be optimised if the discrete grid z is symmetric around zero, i.e. if it satisfies z −i = −z i .Then A m and B m just have to be computed for all z i ≥ 0 and the negative values follow by symmetry.This is the case for the example grid z above.
Samples of the GRF on the sphere are generated with Alg. 2 based on the pre-computed families of matrices A, B, and B eq .Since the computational cost to generate white noise is negligible, the complexity of the algorithm reduces to (2n + 1) FFT in 1d, which makes it computationally fast.Therefore the algorithm is attractive if many samples have to be computed.An example are ice crystals, which can be modelled by lognormal random fields [15].For more information on the relation of lognormal and Gaussian random fields, the reader is referred to [9].A method to validate that a method for sampling a GRF is appropriate and that it converges is to compute the covariance function via the examination of many samples and compare it to the analytic one inferred from the angular power spectrum.We have used the GRF with angular power spectrum from Eqn (11) and corresponding covariance function which is plotted in the left two panels of Fig. 3 as solid blue line.
In order to analyse the errors of our method we have constructed filters at multiple resolutions of n θ ∈ {4, 8, 16, 32}, keeping m max = n θ and n φ = 2n θ (i.e.so the maximum angular separation between adjacent grid points is π/n θ ).We generated N := 320, 000 samples (T n θ j , j = 1, . . ., N ) on all resolutions to estimate the covariance by Cov(x, y) := N −1 N j=1 T n θ j (x) • T n θ j (y) and to compare it to the theoretical one.The dotted and dashed lines in the left two panels of Fig. 3 show the results for the different n θ .The left figure is based on equatorial evaluations while the middle one estimates the covariance along meridional lines.The error was computed by taking on each grid the maximum over all grid points in a set S, which was once the equator and once the meridian, of the difference of the theoretical and statistical covariance, i.e. the error e n θ was computed by e n θ := max

Figure 1 .
Figure 1.Random walks g 0 and (the real part of) g 5 in the upper and lower panels respectively, for the angular power spectrum given in Eqn (11).The black line indicates the walks, whilst the grey shaded region indicates the ± standard deviation E Re(g m ) 2 1/2 .

Figure 2 .
Figure 2. Left to right, visualisation of the process of building the random field starting from the equator, i.e. at each iso-latitude line (constant z) we conditionally sample the g m (z) based on the previous line (including derivatives) and gradually work our way north and south.

2 Figure 3 .
Figure 3. Error analysis for an example GMRF.The left and middle panels estimate the covariance along equatorial and meridional lines respectively, and the analytic covariance in blue.The right panel indicates the convergence of the error as a function of n θ .
x,y∈S |Cov(x, y) − C T (x, y)|.The results are shown in the right panel of Fig. 3.The maximum error on the covariance function falls as m −3/2 max (where n θ = m max ) as can be seen in the error plot.