Simulation and Visualization of Spherical Distributions

0 downloads 0 Views 2MB Size Report
Feb 22, 2018 - spherical distributions on the surface of the unit sphere S2 ..... We plot the histogram drawing a column with height npixnk/4πn over each quadrilateral. ..... Gorski, K. M., E. Hivon, A. J. Banday, B. D. Wandelt, M. Hansen, F. K ...
Simulation and Visualization of Spherical Distributions Gy. Terdik, S. Rao Jammalamadaka, B. Wainwright February 22, 2018

Abstract In this paper, we consider the simulation, visualization, and …tting of such spherical distributions, in support of the dictum, “A picture is worth a thousand words." In a recent paper, Inference for spherical distributions via harmonic analysis (0), the …rst two authors considered new models and inference for directional data in 3-dimensions. Here we provide computational algorithms to simulate several spherical models and in select cases, also provide alternate and improved algorithms for some existing models so that a user can compare alternate approaches for generating such random variates. The algorithms are made available in a MATLAB package titled ‘3D-Directional Statistics, Simulation and Visualization’.

1

Introduction

Vector space representation provides a very e¢ cient method for displaying and analyzing spherical data, both in the natural world as well as for the theoretical framework. Any further exploration and analysis in this area depends on associated algorithms and related software. We consider spherical distributions on the surface of the unit sphere S2 embedded in R3 , with the aim of validating and testing the theory presented in (0), as well as in related papers by others on this topic. We develop the necessary computational tools to achieve this goal, and produce what we believe will be a valuable resource for scientists interested in statistical analysis of directional data in 3-dimensions. These tools are provided in the form of a MATLAB package titled ‘3D-Directional Statistics, Simulation, and Visualization. We start with a summary of the Generalized Fisher-Bingham (GFB) family of distributions, and point out the structure and relationship between various subfamilies therein. We review and reconsider earlier works of Wood (0), Kent (0), and others for the simulation of selected distributions belonging to this GFB family. A recent paper by Kent et al ((0), with an R package considers simulations on spheres and related manifolds. We take advantage of recent software tools and make appropriate modi…cations, needed for our speci…c context. Besides building on existing techniques and …lling out the GFB family of distributions, our work considers new spherical distributions characterized by their spherical harmonics as discussed in (0). In particular, we provide visualizations and simulations of densities de…ned by both real and complex valued spherical harmonics. As mentioned before, the main impetus for this computational exploration is in support of the theoretical work given in (0). Visualization of spherical distributions is made possible in 3-dimensions, and we plot the densities and histograms on the surface of the unit sphere in high relief, as opposed to the more typical heatmap representation. The topographical composition of the plots (density, simulated data, and histogram) provides a very clear graphical representation. In Section 2, a brief account of the GFB family of distributions is given, along with a schematic diagram of the relationships between GFB subfamilies. We then describe the inter-relationships 1

for the various subfamilies and the background theory needed for later simulations. Section 3 describes how a histogram for a random sample of observations on the unit sphere S2 , may be plotted. Section 4 includes the various algorithms for the simulations and visualization, along with some needed explanations. In the …nal section, we conclude with a spherical model which is appropriate for the solar photospheric activity (sunspots), together with the real data set, and an appropriate model that …ts. The MATLAB package which is provided as a Supplement to this paper, contains various MATLAB scripts for generating the di¤erent spherical models described in this paper, as well as tools for implementing other manipulations on spherical data such as plotting, etc.. .

2

GFB family of distributions

We consider a density function f (e x) on the unit sphere S2 in R3 , where e (#; ') = (sin # cos '; sin # sin '; cos #)> ; x e=x

with colatitude # 2 [0; ] and longitude ' 2 [0; 2 ].

Remark 1 We shall use 2 di¤ erent notations for a density viz. f (e x) and f (#; '), the main di¤ erence between them being that f (e x) corresponds to the measure (de x) = sin #d#d', while f (#; ') includes sin # in it, and corresponds to the measure d#d' on the set (#; ') 2 [0; ] [0; 2 ]. For instance, let X be a random unit vector which is distributed uniformly on S2 (see (0), Section 9.3.1), then the Uniform density f (e x) = 1=4 , x e 2 S2 is constant, at the same time the coordinates ( ; ) have probability density 1 f (#; ') = sin #; 4 therefore [0; 2 ].

and

are independent,

is distributed as (sin #) =2 on [0; ] and

is uniform on

A consequence of this to the simulation of random variates on the unit sphere S2 is the following. One may simulate a random variate ( ; ) according to the density f (#; ') and then use x e( ; ) = (sin cos ; sin sin ; cos )> for a random point on S2 , or simulate directly a random variate e 2 S2 according to the density f (e X x). A distribution is considered uni-, bi-, and multi-modal, if it has one or more modes. In case there are two modes which are opposite, i.e. there is an axis joining the two modes, we call this distribution bipolar. If the mass is concentrated around the main circle, it will be called a girdle distribution. Examples below, will make these notions clear. One of the earliest and commonly used models for spherical data is the (unimodal) von MisesFisher distribution (0) which can be extended to an antipodally symmetric model, as given by the Dimroth (0) and Watson (0). Such antipodally symmetric models were further generalized by Bingham (0), and these models, belonging to a particular set of exponential type distributions, shall be called the GFB family. It has several subfamilies according to the number of parameters, the Figure 1 shows a Diagram of Relationships between GFB Families of Distributions. The most general GFB family, GFB8 , contains 8 parameters, and can be characterized by the density (0), f8 x e; e0 ; ; A = exp 2

e0 x e+x e> Ae x ;

(1)

Figure 1: Relationships Between GFB Family of Distributions where = denotes equality up to a multiplicative constant and where e0 2 S2 , A is a symmetric 3 3 matrix and e0 x e denotes the usual inner product. Matrix A has the form A = M ZM > , where i h M = e1 ; e2 ; e3 is an orthogonal matrix and Z = diag ( 1 ; 2 ; 3 ) is a diagonal matrix. Letting be an arbitrary constant, we can show that changing the matrix A to A1 = M Z1 M > in (1), where Z1 = diag ( 1 ; 2 ; 3 ); (2)

the density (1) will not change. To avoid identi…ability problems it is necessary to impose some constraints. Setting = ( 1 + 2 + 3 ) =3, one usually assumes that tr (A) =

1

+

2

+

3

= 0:

(3)

Under this assumption 3 = 1 2 , i.e. Z is given by two parameters 1 and 2 . The unique set of parameters of the density (1) has a cardinality of 8. These are 1. the parameter , 2. two angles (# ; ' ), which de…ne e0 = (sin # cos ' ; sin # sin ' ; cos # )> , 3. the two eigenvalues

1,

2,

of A, and

4. three Euler angles which de…ne the orthogonal matrix M , considered as a rotation matrix. Using the terminology of Kent in (0), this is the GFB8 model, and has the density (1) of the form, ! 3 X 2 f8 x e; e0 ; ; 1 ; 2 ; M = exp e0 x e+ e : k ek x k=1

3

If we set is given by,

=(

1

+

2 ) =2

in (2), an equivalent form of (1) can be derived such that the density

f8 x e; ; ; ; e0 ; M = exp

e0 x e+

e e3 x

2

+

e e1 x

2

e2 x e

2

:

(4)

In this paper, we shall consider densities of the form (4). In this form, the set of parameters ; ; and satisfy the following: Condition 1 The parameters of the density (4) ful…ll:

2 R,

0,

2 R.

Remark 2 Notice, we allow for 2 R, however a sign change of is equivalent to changing either e0 to e0 , or x e, since the quadratic form in the density (4) is invariant under transformation e to x x e to x e. The sign change of will interchange hemispheres only, therefore modulus j j, in some cases, can be considered as the parameter of concentration. If 0, then x e;

f8 x e; ; ; ; e0 ; M = f8

= f8 x e;

; ; ; e0 ; M

; ; ; e0 ; M :

In terms of colatitude and longitude one can use the transformation # ! for getting x e! x e.

#, and ' ! ' + ,

We mention the GFB8 distribution here for completeness, but in practice we will make use of convenient restrictions, discussed in the next section, which will allow us to reduce the number of parameters without loss of generality or ‡exibility.

2.1

Model GFB6

We apply a restriction on the GFB8 by setting either e0 = e3 , or by assuming e0 is collinear to e3 in (4). In this way, we can reduce the number of parameters by two i.e. by the two angles (# 0 ; ' 0 ), which de…ne e0 . The resulting GFB6 model has a density given by, f6 (e x; ; ; ; M ) = exp

e3 x e+

e3 x e

2

+

e1 x e

2

e2 x e

2

:

(5)

We can split up the rotation, which transforms the original xyz system into the orthogonal h i system de…ned by M = e1 ; e2 ; e3 , into two separate rotations. The …rst rotation, Ge ;Ne , will e = (0; 0; 1)> to e , i.e. G rotate the North pole N e 3

e = e .The rotation G e 3

eN ;N 3

3

e ;N 3

can be constructed

e and e de…ne a plane with normal vector N e e (cross in the following way. The vectors N 3 3 e e be the axis of rotation and rotate N e to e . This rotation depends product). Now, let N 3 3 solely on e3 , i.e. by the two angles # and ' of e3 . When we rotate the sphere by Ge ;Ne , the 3

plane of rotated x and y axes coincides with the plane de…ned by e1 and e2 , since e3 is now perpendicular to both planes. Next, using e3 as the axis of rotation, we rotate the sphere by an angle 2 [0; 2 ] such that e1 coincides with the rotated x-axis, and e2 coincides with the rotated y-axis. Let this rotation be denoted by Ge ;xy . These three angles # , ' and , called Euler 1;2 angles, the rotation from the original orthogonal system to the orthogonal system h characterize i M = e1 ; e2 ; e3 . 4

Note here that the rotations from one system to another one are not unique and during simulations we shall apply the above rotation for the densities, their simulations, and histograms. The six parameters of Model GFB6 are then ; ; and M . If e3 is known we can apply Ge ;Ne 3

e and (5) will have the form and rotate it to the North pole N e; f6 x e; ; ; ; N

= exp

e11 x e

x e3 + x e23 +

2

where again, x e = (e x1 ; x e2 ; x e3 ), and e1k are the transformed ek , by Ge

density in the new coordinate system is e; 0 = e f6 x e; ; ; ; N

e and For simplicity, if e3 = N

x e3 + x e23 +

(xe21

x e22 )

=e

e12 x e

3

e ;N

2

;

. Applying Ge

cos #+ cos2 #+ sin2 # cos 2'

1;2

;xy ,

the

:

= 0, we introduce the notation

e ; f6 (e x; ; ; ) = f6 x e; ; ; ; 0; N

and call it the canonical form. The mean direction e of the model GFB6 , given by (5), is characterized by a constant times e , in particular if = 0, then e is unde…ned (e = 0, see (0) for details). M >N

e if and only if = 0 (0). An Remark 3 The Model GFB6 is rotationally symmetric with axis N example of rotational symmetry of GFB6 , when 6= 0, is given in Remark 6, where the axis of rotation is the y axis. From now on we consider densities in the canonical form and hsimulate random variates when i e and e3 = N = 0. If we are given a matrix of rotation M = e1 ; e2 ; e3 , then we apply this rotation as the last step of the simulation. As we have seen above, this rotation can be given by e to e , then use e as the axis of rotation and rotate the e3 and angle , such that we rotate N 3 3 sphere by angle . This is the reverse rotation from what we described above. Formally, we apply the product of the two rotations GNe ;e Gxy;e . (The product of two rotations Ge ;Ne Ge ;xy is 3

1;2

3

1;2

again, a rotation.) Considering the density at transformation x = cos #, as is done in Wood (0), x e1 =

p

1

x2 cos '; x e2 =

p

1

x2 sin '; x e3 = x;

(6)

with the derivative dx = sin #d#, we obtain what we will hereafter refer to as, the basic form of the density f6 , given by, g6 (x; '; ; ; ) = e

x+ x2 +

= e (1

(1

x2 ) cos 2'

x2 ) cos 2'

e

x+ x2

:

(7)

This is the joint density in x and ', and can be considered as the product of two densities, where exp x + x2 is a density in x, and exp 1 x2 cos 2' is the conditional density of ' given x. More precisely g6 (x; '; ; ; ) = g jX ('jx; ) g6;X (x; ; ) ; 5

where g6;X (x; ; ; ) = exp

x + x2

Z

2

e (1

x2 ) cos 2'

d' = I0

x2

1

e

x+ x2

:

0

It follows from (7) that g

jX

('jx; ) = e (1

x2 ) cos 2'

:

(8)

The densities g6;X (x; ; ; ) and g jX ('jx; ) will be called the marginal density, and conditional density respectively. The conditional density g jX remains the same throughout this paper, and therefore we do not refer to the speci…c subfamily to which it corresponds. Remark 4 When X = x is given, the conditional density (8) follows vMF distribution (see Section 2.6) with parameter 1 x2 and is a function of 2'. It is worth mentioning that g jX ('jx; ) is not a vMF distribution on the unit sphere S2 since the sin 2' component is missing from (8), but it is vMF distributed on the unit circle S1 . We now consider special cases of Model GFB6 , when one of the basic parameters ; ; is zero. Although the densities in these cases follow directly from the densities f6 and g6 , we list them individually in order of decreasing complexity. The algorithms for the simulation of these models will be given in Section 4, in reverse order, incrementally increasing the number of parameters and the model complexity.

2.2

Kent Model GFB5;K

Let = 0, in (5). Then, the number of parameters in f6 (e x; ; ; ; M ) is reduced by one (i.e. by parameter ), and has the form f5 (e x; ; ; M ) = exp

e+ e3 x

e1 x e

2

e2 x e

2

which de…nes the …ve parameter model GFB5;K . The …ve parameters are canonical form 2 2 f5 (e x; ; ) = e xe3 + (xe1 xe2 ) : In terms of # and '

f5 (e x; ; ) = e

cos #+ sin2 # cos 2'

;

;

(9) ; ; and M , with

(10)

see (0). If we apply transformation (6) then the corresponding basic form is g5 (x; '; ; ) = g

jX

('jx; ) g5;X (x; ) ;

where g5;X (x; ; ) = I0

1

x2

e x;

(11)

see (8) for conditional density g jX . Furthermore, if 2 the distribution is unimodal with mode at e3 , which is the case Kent originally considered in (0). If 2 > the distribution is bimodal, with modes at longitude ' = 0 and , with the third coordinate, x e3 , de…ned by the equation cos # = =2 for both modes.

Remark 5 All MATLAB scripts described in this paper are listed in Supplement B, and are contained in package ‘3D-Directional Statistics, Simulation and Visualization’. 6

Figure 2: Kent density, left: bimodal, 2 > , modes are at # = =4, and ' = 0, ; right: unimodal, 2 When 2

, the parameters in this model have the meaning (see (0))

1. j j represents the concentration 2. e3 is the mean direction (pole or mode)

3. e1 and e2 are, respectively, the major and minor axes of constant probability ellipses near the mode, and are determined only up to sign. 2.2.1

Equal area projection and separability of FB6

Equal area projection of spherical densities provide some possibility of simulations on a rectangle in the plain. As mentioned in (0), in the particular case when 2 , model GFB5;K represents Lambert’s equal area projection of the sphere y1 = r cos ', y2 = r sin ', r = sin (#=2) ;

(12)

and separates the density (10) by coordinates y1 and y2 . The inverse of this transform cos # = 1 sin ' = cos ' =

2 y12 + y22 ;

(13)

y2 p 2 ; y12 + y22 y2 p 1 ; y12 + y22

will be useful during simulations. The transformed Kent model FB5;K writes f5 (y1 ; y2 ; ;

1; 2)

=e

2(

2 )y12 4 y14

e

2( +2 )y22 +4 y24

;

see the Proof of the Lemma below. Namely the transformed coordinates become independent. We show that the opposite of this statement is also true. 7

Lemma 1 Consider the model FB6 with density given in the form ! 3 X 2 f6 (e x; ; 1 ; 2 ) = exp x e3 + ek : kx

(14)

k=1

The equal area projection f6 (y1 ; y2 ; ; 1 ; corresponds to the Kent model FB5;K .

2)

of (14) will be separable in y1 and y2 if only if f6 (y1 ; y2 ; ;

Proof. Let us start from the FB6 density f6 (e x; ;

1; 2)

= exp

Now, apply the equal area projection (12). We have

x e3 +

x e22 = 4 1

hence f6 (y1 ; y2 ; ;

1; 2)

x e23 = 1

= exp

e2k kx

k=1

!

:

2r2 ;

x e3 = cos # = 1 x e21 = 4 1

3 X

r2 y12 ; r2 y22 ;

4r2 1

r2

2 r2 + 4 1

r2

2 1 y1

+

2 2 y2

3r

2

;

(15)

where r2 = y12 + y22 . Now, the exponent in details writes 2 4

1

y12 + y22 + 4 1 y12 +

y12 + y22

y14 + y12 y22

+4

4

2 2 y2 3 4 2 2 2 y2 + y1 y2

3

y14 + 2y12 y22 + y24 :

The density (15) will be separable in y1 and y2 i¤ 1

+

2

2

3

= 0:

(16)

The sum 1 + 2 2 3 is invariant under the transformation (2), therefore setting = ( 1 + 2 ) =2, in (2), (16) implies and implied by = 3 ( 1 + 2 ) =2 = 0, in other words the model is the Kent model FB5;K .

2.3

Bingham Model GFB5;B

An alternate way of reducing the number of parameters in (5) by one, is setting the density,with canonical form fB (e x; ; ) = e

x e23 +

(xe21

x e22 )

=e

cos2 #+ sin2 # cos 2'

:

= 0. This yields

(17)

Application of transformation (6) gives the basic form gB (x; '; ; ) = g

jX

('jx; ) gB;X (x; ) ;

where gB;X (x; ; ) = I0

1

x2

e

x2

;

see (8) for conditional density g jX . Here, the marginal density gB;X contains the expression exp x2 which corresponds to the DW distribution, de…ned in Equation (19)). 8

1; 2)

Remark 6 In a particular case, when

= , the density (17) has the form

fB (e x; ; ) = e

x e23 +

(xe21

x e22 )

2 x e22

=e

;

(18)

This model (18) is a rotation of the DW model (see Equation (19)) with negative parameter (we remind the reader that > 0) and therefore (18) is a girdle distribution according to the main circle x e2 = 0. Let us …x and change and consider three alignments: if < , then it is bipolar with modal direction x axis, if = , then it is girdle, …nally, if < , then the modal direction is the North e , see Figure 3. pole N

Figure 3: Bingham model; = 3:2, for all cases, left to right respectively, here e = (0; 0; 1)> , and

2.4

= 1:1 < , = 0.

= 3:2 =

and

= 4:1 >

from

Model GFB4;

We now consider the simplest form when the conditional density g jX is not constant, namely when the and are not independent random variables. Setting either = 0 and = 0 in (5), or = 0 in (9), or = 0 in (17), we get the density function which is a four-parameter family of distributions, with canonical form 2 f (e x; ) = e (xe1

x e22 )

=e

sin2 # cos 2'

;

The basic form x2 ) cos 2'

g (x; '; ) = e (1 coincides formally with the conditional density g uniform, since g (x; '; ) = g

jX

jX .

;

Nevertheless, the marginal density is not

('jx; ) g

;X

(x; ) ;

where g

;X

and as we have already mentioned, g

(x; ) = I0

jX

1

x2

;

follows vMF distribution on the circle see (8). 9

2.5

Model GFB4

Setting = 0, in (5) we reduce the number of parameters by two ( , and angle canonical form is 2 2 f4 (e x; ; ) = e xe3 + xe3 = e cos #+ cos # :

) the result in

This density does not depend on longitude '. Instead, it depends only on cos # and hence, is rotationally symmetric (see Lemma 4 (0)). Transformation (6) provides the basic form g4 (x; ; ) = e A particular case of Model GFB4 when

2.6

x+ x2

:

= 0, is the following three parameter family:

Dimroth-Watson Model GFB3;DW

The Dimroth-Watson Distribution (DW) (0) distribution is given by the density function, fW x e; ; e =

2 1 1 e (e xe) = e M (1=2; 3=2; ) M (1=2; 3=2; )

cos2 #

;

(19)

where M (1=2; 3=2; ) is Kummer’s function (not to be confused with the orthogonal matrix M described above) and where # = arccos e x e , (0). Either setting = 0, in Model GFB4 , or = 0, in the Kent Model GFB5;K , we arrive at the most basic model on the sphere viz. the von Mises-Fisher distribution. Model GFB3;vM F

with basic form

The widely used von Mises-Fisher Model (vMF) density is given by fvM F x e; ; e = gvM F (x; ) =

3

p (2 )3=2 I1=2 ( ) p (2 )3=2 I1=2 ( )

e

ex e

;

(20)

e x:

Histogram

A histogram for a random sample on the unit sphere S2 assumes an equal-area discretization of the sphere. We consider the HEALPix (Hierarchical, Equal Area and iso Latitude Pixelization) discretization, a detailed description of which can be found in (0). In the …rst step of the pixelization the sphere is partitioned into 12 equal-area spherical quadrilaterals (pixels), and in each subsequent step, all the existing pixels are divided into 4 equal-area quadrilaterals. HEALPix is a discretization with the resolution parameter nside (number of steps division, which is a power of 2) and total Pnof pix number of pixels equal to npix := 12n2side , such that k=1 nk = n, and each with an area of 4 =npix . e If we are given a random sample X j , j = 1; 2; : : : n, on the sphere S2 , then for each pixel/ quadrilateral k ; k = 1; 2; : : : npix we set an integer nk which counts the number of the sample elements contained in the pixel k . We use the nested numbering scheme for ordering pixels, where th pixel according to this scheme. The nested scheme is appropriate for decreasing the k is the k resolution, since one can easily accumulate the samples included in 4 ‘neighboring’pixels. 10

We de…ne the histogram H (e x) such that it is constant over a quadrilateral k and the integral over the sphere is 1: npix nk H (e x) = ; x e 2 k: 4 n We plot the histogram drawing a column with height npix nk =4 n over each quadrilateral. For ej , j = 1; 2; : : : n = 212 , be a random sample from the uniform distribution and instance, let X 3 nside = 2 , so that npix = 768. We plot the sample and the corresponding histogram:

Figure 4: Uniform sample and its Histogram An important feature of the histogram lies in the plot construction. Mathematically, when the columns from each quadrilateral are extruded from the surface of the sphere, the height is measured normal to the center of the pixel, and the volume is given as that height times the area of the quadrilateral, as described above, and as is as expected. However, graphically we also extrude all of the pixel edges normal to their respective location on the sphere. This results in taller columns having larger patches and shorter patches having smaller patches at their respective termini, and stands that maintain pixel surface area at all elevations, which forces adjacent columns to becoming increasingly separated as column height increases, and results in a pin cushion type histogram.

4

Simulation of Random Variates on the Sphere

There will be some common features of all simulations below. These are the following: 1. We consider the case 0, in formulae, but also handle the the case 0, during simulation. e with j j and as a …nal step (but before rotation) change the We simulate a random variate X e (see Remark 2). e to X variate X

2. All algorithms below concern the case when the frame of reference is xyz, with the modal/mean e. direction as the North pole, i.e. e = N 3. The plots are generated by the following parameters: Sample size is n = 212 = 8; 192, resolution of the discretized sphere S2 is nside = 23 , which yields a total pixel count of npix = 768. The resolution for theoretical density plots is 101 101 of the set of angles (#; ') 2 [0; ] [0; 2 ]. 11

i h 4. We characterize a rotation corresponding to M = e1 ; e2 ; e3 , by a vector e and an angle , such that e3 represents e and e1 , e2 de…nes the angle , see Subsection 2.1 for details. See Algorithm 1, in Supplement C for the case, when a vector e and an angle are given. Note, P ( + x) = P ( x ), hence when an angle of a random variate is changed by , then the corresponding density is changing by , see .Supplement C for more details.

4.1

Acceptance-rejection method

For the simulation of random variates from the various distributions presented here, we make frequent use of the standard acceptance-rejection method. For a detailed account of this classic simulation technique, see (0), (0), but a general overview of the method for any particular distribution is as follows. We wish to sample random variate X from a calculable target distribution with density fX (x), for which the simulation process is either exceptionally di¢ cult, or perhaps even unknown. Because fX (x) is calculable, we can write the density fX (x) = cg (x) h (x), where the constant c 1, 0 < g (x) 1, and h (x) is a probability density function from which we know how to sample. The algorithm of this general method based on testing the inequality U g (Y ), where U is uniform on the interval (0; 1), and if it is ful…lled, then Y will be accepted as a random variate from fX (x). The corresponding algorithm is given in (Sup.C.Alg.2) In practice, we seek a density h (x) such that fX (x)

c1 h (x) ;

where c1 1, then set g (x) = fX (x) =c1 h (x) and denote to the denominator as the envelope, and use the above algorithm. To maximize algorithmic e¢ ciency, the acceptance ratio 1=c1 should be maximized such that the constant c1 is as close to one as possible, which naturally depends on the choice of density h (x). If feX coincides with fX except some constant cf , fX = feX , and similarly e h coincides with h e e e except some constant ch , hX = hX , and fX h, then cf feX (x) = fX (x)

cf e h (x) =

cf e ch h (x) = c1 h (x) ; ch

where 1=c1 = ch =cf is the acceptance ratio. Therefore the test can be performed by checking the inequality fX (Y ) feX (Y ) U g (Y ) = = ; (21) e c1 h (Y ) h (Y ) where again Y and U , are distributed by h (y) and uniform respectively. This method has been used extensively by Wood (0), (0), and we employ this technique in many ways. Ulrich (0) proposes a general method for simulating a rotationally symmetric variable.

4.2

Simulation of FB families

We shall describe the simulation of the canonical variates. The necessary rotation can be done separately in each case and is included in the appropriate scripts of the MATLAB package ‘3DDirectional Statistics, Simulation and Visualization’(see Supplement C for examples). We shall use the well known basic algorithms for simulation of spherical uniform, vMF and DW random variates (Sup.C.Alg.3-6). 12

The inequality (21) shows that for the simulation we do not need the normalizing constants, although they are needed for calculating the acceptance ratios. If these constants are not available analytically, we use numerical integration for calculating the acceptance ratios. 4.2.1

Model GFB4

GFB4 generalizes both the vMF and DW models. We use the envelopes proposed by Wood (0) in the application of acceptance-rejection sampling as described above. The density in basic form 2 g4 (x; ; ) = e x+ x ; implies that the longitude = 2 U , where U is uniform distributed independently from the colatitude , and hence, we shall concentrate on simulation of X = cos . Also, we assume that parameters and are not identically zero otherwise the model is simpli…ed to model either vMF or DW. We consider three cases according to the relation between the parameters and . 1. If < 0, 0 2 , complete the quadratic form in the exponent and rewrite g4 as g4 (x; ; ) = e

(x+ =2 )2

; x 2 [ 1; 1] ;

and use the Gaussian envelope. The acceptance ratio is large if we assume that the mean =2 belongs to [ 1; 1], which is the case under this assumption. The algorithm of this case is given in the …rst part of (Sup.C.Alg.7). 2. If < 0, 2 , then we use vMF gvM F (x; + 2 ) on S2 , as an envelope 3. If > 0, an envelope composed of a mixture of gvM F (x; + ) and gvM F (x; ) vMF distributions is used. The di¤erence between our method (Sup.C.Alg.7) and the one described in (0), is how we partition the case where < 0. 1 Some particular cases with interesting features arise in the simulation of models in the GFB5 family. In this vein, we consider GFB4; , which demonstrates the di¢ culty of combining two algorithms, as well as the problem of simulation of according to the conditional density g jX . 4.2.2 If

Model GFB4; ,

6= 0,

= 0,

= 0, the density in basic form is given by x2 ) cos 2'

g (x; '; ; ) = e (1

;

and has marginal g

;X

(x; ) = I0

1

x2

;

and conditional g jX (8) densities. The simulation of the marginal X is based on the inequality 1 I0 cI

1

x2

c (p1 fW (x; 2cI

) + p2 fW (x; )) :

With the mixture of two DW densities, one is bipolar, > 0, and the other one is girdle, where Z 1 cI = I0 1 x2 dx: 1

1

Note, (0) Procedure FB4 , p. 890 has a misprint. The correct expressions are

13

1

=

2 p

2

;

2

=

p2

2

< 0.

Now, we use the acceptance-rejection method for simulation of X = cos , with an acceptance ratio of 2cI =c that is decreasing as is increasing. The corresponding algorithm is Algorithm 8, Supplement C, see Figure 5. The simulation of longitude according to the conditional density g jX is given by simulating 2 as a vMF distributed random variate on S1 (see Remark 4). It yields a value in [0; ], and hence, itself will be an element in [0; =2]. The density function g has the same value at , , + , and + , therefore we shall extend the simulated value randomly. The algorithm (Sup.C.Alg.9), will be used in more general cases as well, since the conditional densities do not change in di¤erent sub-families.

Figure 5: Model GFB4;

4.2.3

Model GFB5;K

Here we consider the Kent model GFB5;K , and note that the equal-area projection simpli…es the problem of simulating two independent random variates.2 Equal-area projection, case 2

This part of the simulation of the Kent model GFB5;K f5 (e x; ; ) = e

(xe21

x e3 +

has been considered by Kent (0) under the assumption, 0

2

x e22 )

;

:

(22)

This is the case when the exponent of the density is a nonincreasing function of # for each ', and when the model is unimodal (see Figure 6). The Kent model, GFB5;K , under transformation (12) has the form 2 4 2 4 f5 (y1 ; y2 ; ; ) = e 2( 2 )y1 4 y1 e 2( +2 )y2 +4 y2 ; which is a product of two densities. Introduce 1

=

2 ;

2

=

+2 ;

4 y14

e

in this parametrization the density has the form f5 (y1 ; y2 ; ; ) = e 2

2

2 1 y1

See subsection 2.2.1 for details.

14

2

2 2 y2 +4

y24

:

(23)

If assumption (22) holds then 0;

1

0;

2

and we use Kent’s algorithm (0), given in Algorithm 10 (Sup.C.Alg.10). We simplify Kent’s algorithm, using a Gaussian envelope instead of the exponential envelope. From Kent’s method, we stop at the …rst inequality and apply the acceptance-rejection method right there. The basic inequality is given by, 1 2 Setting

=

p

8 , and

2

1 2

w2

2

jwj ;

; > 0:

= 1, we have

exp

2

2 1 y1

4 y14

2 1

which gives the Gaussian envelop with variance exp

2

2 2 y2

1 2

exp

+ 4 y24

1 4 2

= 1= 4

1

1 (4 2

exp

1

+

+ 2

p 8

p

8

y12 ; . Similarly

8 ) y22 ;

yields a Gaussian envelop as well, with variance 22 = 1=4 .3 . We combine these two and use acceptance-rejection method in the …rst part of Algorithm 11 (Sup.C.Alg.11).

Figure 6: Model GFB5;K , unimodal: 2

, from left to right: density, sample, histogram

Equal-area projection, case 2 > We are also interested in the case when the density increasing and decreasing in # around ' = 0. 0

2 ;

In this case, 1

=

2

0;

2

=

+2

0:

Let us start with the …rst component of (23), exp 2 1 y1

p (y1 ) = 3

We have corrected a misprint in (0) in our algorithm

15

2

2 1 y1

2 y14 ;

4 y14 . The polynomial

Figure 7: If 2 > , then the model GFB5;K , is bimodal in the exponent is symmetric p to zero. We restrict the variable y1 such that jy1 j two maximums at y0 = (1 =2 ) =2, where

1, hence we have

2

p (y0 ) =

2

1

:

2

Therefore we separate the interval [ 1; 1] and use Gaussian envelope exp

2

2 1 y1

4 y14

exp

2

2

1

2

y1

y0+

2

+ p (y0 )

;

(24)

on [0; 1]. This envelope will exactly match the target density at the maximum, otherwise it is greater. Similarly exp

2

2 2 y2

+ 4 y24

exp

(2

2

4 ) y22 = exp

2 y22 ;

(25)

provide a Gaussian envelop as well, with variance 22 = 1=4 . The second part of Algorithm 11 (Sup.C.Alg.11) is based on these two inequalities (24) and (25). If 2 > , then the model is bimodal, but not bipolar, and the cosine of the angle, , between the modal directions is cos = =2 . We put =2 = 1=2, and hence = =3 (see Figure 7). 4.2.4

Model GFB6

The Kent model GFB5;K and the Bingham Model GFB5;B are included here since, as we shall see, there is only a small di¤erence either if = 0, or = 0. If = 0; we have payed particular attention to the case = 6= 0, see Remark 6. We repeat the method applied for the F B , 6= 0, with and , then we use a mixture of two F B4 densities. The corresponding algorithms can be found in (Sup.C.Alg.9) and (Sup.C.Alg.12).

4.3

Spherical Distributions and Simulation of spherical harmonics

If a density f (e x) is continuous then it has series expansion in terms of spherical harmonics Y`m , f (e x) =

1 X ` X

`=0 m= `

16

m am x) : ` Y` (e

(26)

Figure 8: Model GFB6 ,

= 1:5;

= 0:61;

= 0:31;

= [1; 1; 1],

= 0;

The coe¢ cients fam ` g can be considered as a characteristic function, they are complex valued, m m am = ( 1) a , and are given by ` ` Z m x) (de f (e x) Y`m (e x) : (27) a` = S2

Several symmetries of distributions are characterized in terms of coe¢ cients am ` , (27), see (0). p p 4 0 0 Notice that the spherical harmonic Y0 = 1= 4 , and hence a0 = 1= 4 is the normalizing constant for f (e x) and (de x) = sin #d#d' is the Lebesgue element of surface area on S2 . The notation is de…ned as the transpose and conjugate of a matrix and just the conjugate for a scalar. For a detailed account of Spherical Distributions and Harmonic Analysis see (0) Let x e (#; ') be a point on the unit sphere S2 , then the spherical harmonics are de…ned by s 2` + 1 (` m)! m m Y`m (#; ') = ( 1) P (cos #) eim' ; ' 2 [0; 2 ] ; # 2 [0; ] ; 4 (` + m)! ` where P`m denotes associated normalized Legendre function of the …rst kind. Real-valued spherical harmonics. Spherical harmonics are, in general, complex valued, due to the dependence of longitude ' given by eim' . Now, eim' is a complete orthogonal system on the circle which is equivalent to the sine-cosine system for real-valued functions. Similarly, real-valued spherical harmonic functions are de…ned as 8 m m 1 m > m>0 < p2 Y` + ( 1) Y` m Y` m=0 Y`;m = (28) > : p1 Y m ( 1)m Y m m < 0 ` ` i 2

The harmonics with order m > 0 are said to be of cosine type, and those with m < 0 of sine type. 2 , when m = 1; 2; 3 5 . Figure 9 contains three densities among Y4;m Example 1 Exponential family class of distributions (0), g (e x) = exp

M X ` X

m bm x) ; ` Y` (e

`=0 m= `

4

Some of the …rst spherical harmonics are listed in (0). One may plot densities according to module square of complex and real spherical harmonics for any given L and 2 all m 2 [ L; L] by the command dx = Density_SphHarm_All(L, m, Real,resolution); if m 2 = [ L; L] then all YL;m will be plotted, see our MATLAB package ‘3D-Directional Statistics, Simulation and Visualization’for detailes. 5

17

Figure 9: Square of real spherical harmonics, L = 4, m = 1; 2; 3 where bm = ( 1)m b` m . The normalizing constant corresponds to b00 and depends on the rest of ` the bm ` parameters, such that the integral is necessarily 1. The likelihood of observations often has this form. In the case of rotational symmetry around axis x e0 ! M X b` P` (cos #) fe (e x) = exp `=0

where # is the angle between x e and x e0 , and P` denotes the Standardized Legendre polynomial (P0 (x) = 1). Example 2 Another useful class of density functions is given by, f (e x) =

1 X ` X

2 m x) dm ` Y` (e

;

`=0 m= `

P P` m 2 where 1 `=0 m= ` jd` j = 1. This class of distributions are of interest in, amongst other topics, the modeling of atoms. In quantum mechanics, Y`;m (e x)2 is considered as a probability density function, and plays an x)j2 is also a density important role in the modeling of the hydrogen atom. The module square jY`m (e function that serves as an example of a rotationally symmetric density function on the sphere, as it only depends on cos #. 4.3.1

Simulation of modulus-square of complex harmonics

Consider the density jY`m (e x)j2 on S2 with respect to Lebesgue measure sin #d#d'. We have jY`m (e x)j2 =

2` + 1 (` m)! m P (cos #)2 ; 4 (` + m)! `

where P`m is associated normalized Legendre function of the …rst kind. jY`m (e x)j2 is rotationally symmetric and 2 jY`m j2 will be a density on [ 1; 1]. More precisely, the function 2 m f`m (x) = cm ` P` (x) ; where cm ` =

2` + 1 (` m)! ; 2 (` + m)! 18

is a density on [ 1; 1]. We have jY`m (e x)j2 = f`m (cos #)2 =2 . For convenience (MATLAB) we use 2 m m the fully normalized associated Legendre function pm ` , such that f` (x) = p` (x) . 2 For general ` and m and pm ` (x) , one can use Forsyth’s method (0), with intervals de…ned by 2 2 2 the zeros of pm ` (x) and Beta envelopes, say. In particular, let ` = 3, m = 2. then p3 (x) has a root at 0 and is symmetric around zero. For generating X, we apply the Neumann Theorem for 2f32 (x), (Sup.C.Alg.13), since the Beta distribution with shape parameters = 3:08 and = 2:5249, proved to be an e¢ cient envelope for the density 2f32 (x). The beta density is given by the function b (x; ; ) = x 1 (1 x) 1 =B ( ; ), and the above shape parameters ( = 3:08 and = 2:5249) were found with the following steps: 1. let ;

> 1,

2. use the relation ( 1) = ( + point (modus) of 2f32 (x), 3. …nd the set of

and

, where xM is the maximum

1

ii.) max min 2f32 (x) =cb (x; ; )

1

x

4. choose a pair

and

under the (simultaneous) constraints:

i.) max 2f32 (x) =b (x; ; ) x

2) = xM , between

and , such that min max 2f32 (x) =b (x; ; ) x

is achieved

We then have, 2f32 (x) b (x; ; ) b (x; ; ) = cg32 (x) h23 (x) ;

2f32 (x) =

with c = max 2f32 (x) =b (x; ; ) , h23 (x) = b (x; ; ), and 0 g32 (x) = 2f32 (x) = (cb (x; ; )) We have found that c = 1:074, showing a high acceptance ratio.

Figure 10: Simulation of density jY`m (e x)j2

19

1.

4.3.2

2 Simulation of real harmonics Y3;2

2 is given by Consider the real spherical harmonics Y3;2 (28). The density function Y3;2

1 1 7 1 2 2 Y32 + Y3 2 = P (cos #)2 ei2' + e 2r 2 4 5! 3 7 1 2 =2 P (cos #)2 cos2 2': 4 5! 3

2 Y3;2 =

i2' 2

2 is the This is a multimodal, non-rotationally symmetric distribution. The density function Y3;2 multiplication of the density of and the density of respectively, which implies that the angles and are changing independently. The simulation of according to the density = P32 (cos #)2 sin #, has been solved during the simulation of module square of complex harmonics above. The simulation of by the density = cos2 ' is based on the following: p Let B be Beta distributed with = 3=2 and = 1=2, and de…ne X = arccos B . Then, from the equality p FX (x) = P arccos B x = P B > cos2 x ;

it follows fX (x) = 2fB cos2 x cos x sin x =

2 cos2 x b( ; )

1=2

sin2 x

Similarly, if B is a Beta distributed variate with

1=2

cos x sin x =

= 1=2 and

4 cos2 x

(29)

= 3=2,

fX (x) = 2fB cos2 x cos x sin x =

2 cos2 x b( ; )

1=2

sin2 x

3=2

cos x sin x =

4 sin2 x

:

The latter of the two formulations for fX (x) is used for the simulation of Y3;2 2 . p We conclude that the density of = arccos B is = cos2 ', on [ =2; =2]. Once we have a random variate on [ =2; =2] with density function depending on cos ' we can easily transform its values periodically to the interval [0; 2m ], say. Algorithm 14 (Sup.C.Alg.14), works for the density f (e x) = P32 (cos #)2 cos2 2'; in this case we choose m = 2, since the longitude ' should have values on [0; 2 ], and we have the random variate 2 on [ =2; =2]. One can generalize this method for density = cos2 k', where k is an integer.

4.4

Simulation of U distribution

Finally, we examine the U distribution (not to be confused with the uniform distribution), which is a simple distribution on the sphere that is not rotationally symmetric. Consider U1 , U2 , U3 uniform on [0; 1], independent variates. Then, we can de…ne, p > 2 e e = (sin cos ; sin sin ; cos ) e 2 S2 , Z Z = [Z1 ; Z2 ; Z3 ] = (U1 ; U2 ; U3 ) = U1 + U22 + U32 , Z 20

2 Figure 11: Simulation of density Y3;2

We have U2 Z2 = Z1 U1 U2 P ( < ') = P < tan (') U1 8 tan (') > < if 2 = 1 > : 1 if 2 tan (') tan ( ) =

0

' < =4 ;

=4

' < =2

and see mathematically that it is not the uniform density function 8 >
: 2 sin2 (')

Now, consider the conditional density f

j

if

0

if

=4

' < =4

(#j') for a …xed

' < =2; = ',

Z1 U1 = ; Z3 U3 U1 < cos (') tan (#) = ') = P U3 8 cos (') tan (#) > < if ' 2 [0; =4] ; # 2 [0; =2] ; cos (') tan (#) 1 2 = ; 1 > : 1 if ' 2 [0; =4] ; # 2 [0; =2] ; cos (') tan (#) > 1 2 cos (') tan (#)

tan ( ) cos ( ) = P(

f

j

< #j

(#j') f (') =

8 > > < > > :

cos (')

16 cos2 (#) cos2 (') 1 16 sin (#) cos3 (') 2

if

' 2 [0; =4] ;

if ' 2 [0; =4] ;

# 2 [0; =2] ; cos (') tan (#)

1

# 2 [0; =2] ; cos (') tan (#) > 1

The U distribution is a unique and interesting example of a distribution that is antipodal, not isotropic and not rotationally symmetric.

21

Figure 12: U distribution.

References Atkinson, A. C. and M. C. Pearce 1976. The computer generation of beta, gamma and normal random variables. Journal of the Royal Statistical Society. Series A (General) 431–461. Bingham, C. 1974. An antipodally symmetric distribution on the sphere. The Annals of Statistics 1201–1225. Dimroth, E. 1962. Untersiichungen aim wechanismiis von blastais und syntexis. Phylliterr and Hodelsen des siidm3lichen Fichtelgebirges I. Die statistische Airswertung einfacher Giirteldi.agranime. Txheim. Man. Pctr. Mitt. 8:248–274. Fisher, R. A. 1953. Dispersion on a sphere. Proceedings of the Royal Society of London A: Mathematical, Physical and Engineering Sciences 217(1130):295–305. Gorski, K. M., E. Hivon, A. J. Banday, B. D. Wandelt, M. Hansen, F. K .and Reinecke, and M. Bartelmann 2005. HEALPix a framework for high-resolution discretization and fast analysis of data distributed on the sphere. The Astrophysical Journal 622(2):759. Kent, J. T. 1982. The Fisher-Bingham distribution on the sphere. Journal of the Royal Statistical Society. Series B (Methodological) 71–80. Kent, J. T., A. M. Ganeiber, and K. V. Mardia 2017. A new uni…ed approach for the simulation of a wide class of directional distributions. Journal of Computational and Graphical Statistics (just-accepted). Kent, J. T. and T. Hamelryck 2005. Using the Fisher-Bingham distribution in stochastic models for protein structure. Quantitative Biology, Shape Analysis, and Wavelets 24:57–60. Mardia, K. V. and P. E. Jupp 2009. Directional Statistics volume 494. : John Wiley & Sons. Neumann, J. v. 1951. Various techniques used in connection with random digits. U.S. Nat. Bur. Stand. Appl. Math. Ser., 12:36–38. Rao Jammalamadaka, S. and G. Terdik. 2017. Inference for spherical distributions via harmonic analysis. arxiv:1710.00253 [stat.me] no.. : UCSB and UD. Rubinstein, R. Y. 1981. Simulation and the Monte Carlo Method. : John Wiley & Sons, Inc. 22

Ulrich, G. 1984. Computer generation of distributions on the m-sphere. Applied Statistics 158–163. Watson, G. S. 1965. Equatorial distributions on a sphere. Biometrika 52(1/2):193–201. Watson, G. S. 1983. Statistics on spheres. Number 6 in University of Arkansas Lecture Notes in the Mathematical Sciences. : John Wiley & Sons, Inc., New York. Wood, A. T. A. 1987. The simulation of spherical distributions in the Fisher-Bingham family. Communications in Statistics-Simulation and Computation 16(3):885–898. Wood, A. T. A. 1988. Some notes on the Fisher–Bingham family on the sphere. Communications in Statistics-Theory and Methods 17(11):3881–3897.

23

Suggest Documents