sphstat.singlesample module

Functions for inferential statistics on a single sample

  • isuniform() tests the null-hypothesis that the sample is drawn from a uniform spherical distribution

  • testagainstmedian() tests the null-hypothesis that the sample has a given median direction

  • rotationalsymmetry() tests rotational symmetry around the known true mean

  • meanifsymmetric() calculates the mean direction under the assumption tha the sample comes from a symmetric distribution

  • testagainstmean() tests the null-hypothesis that the sample has a given mean direction

  • isaxisymmetric() tests the null hypothesis that the sample comes from a rotationally symmetric distribution

  • isfisher() tests the null hypothesis that the sample comes from a Fisher distribution

  • outliertest() identifies outliers in the sample

  • fisherparams() calculates the parameters of the Fisher distribution that the sample is drawn from

  • meantest() tests against a mean value

  • kappatest() tests against a concentration parameter

  • kentparams() calculates the parameters of the Kent distribution that the sample is drawn from

  • kentmeanccone() calculates the confidence interval for the mean direction for a Kent distributed sample

  • isfishervskent() tests the null hypothesis that the sample is drawn from a Fisher distribution as opposed to a Kent distribution

  • bimodalparams() calculate the parameters of a bimodal (e.g. Wood) distribution

sphstat.singlesample.bimodalparams(samplecart: dict, modesfar: bool = False) dict[source]

Model parameter estimation for a bimodal distribution 1

Parameters
  • samplecart (dict) – Sample to be tested in ‘cart’ format

  • modesfar – Flag for indicating whether the two modes of the data are far.

  • modesfar – bool

Returns

Model parameters for the Wood distribution

Return type

tuple

1

Wood, A. (1982). A bimodal distribution on the sphere. Appl. Statist. 31, 52-58.

sphstat.singlesample.fisherparams(samplecart: dict, alpha: float = 0.05) dict[source]

Parameter estimation for the Fisher distribution 2, 3

Parameters
  • samplecart (dict) – Sample to be tested in ‘cart’ format

  • alpha (float) – Calculate (1-alpha)% CI for kappa

Returns

Dictionary with the keys… - mdir: Mean direction (theta, phi) (tuple) - kappa: Concentration parameter (float) - thetaalpha: Semivertical angle (float) - cikappa: (kappalow, kappahigh) is the (1-alpha)% CI for kappa (tuple)

Return type

dict

2

Watson, G. S. & Williams, E. J. (1956). On the construction of significance tests on the circle and the sphere. Biometrika 43, 344-352.

3

Watson, G. S. (1956). Analysis of dispersion on a sphere. Mon. Not. R. Astr. Soc. Geophys. Suppl. 7, 153-159.

sphstat.singlesample.isaxisymmetric(samplecart: dict, alpha: float = 0.05) dict[source]

Test for rotational symmetry about the mean direction

Parameters
  • samplecart (dict) – Sample to be tested in ‘cart’ format

  • alpha (float) – Type-I error level

Returns

Dictionary containing the keys: - Pn: Test statistic (float) - cval: Critical value to test against (float) - pval: Actual p-value (float) - testresult: Test result (bool)

Return type

dict

sphstat.singlesample.isfisher(samplecart: dict, alpha: float = 0.05, plotflag: bool = False) dict[source]

Goodness-of-fit of the data with the Fisher model 4

Parameters
  • samplecart (dict) – Sample to be tested in ‘cart’ format

  • alpha (float) – Type-I error level

  • plotflag (bool) – Flag to plot the Q-Q plots

Returns

Dictionary containing the results of three tests: - ‘colatitute’: Results of the colatitude test as a nested dictionary

  • ’stat’: Test statistic (float)

  • ’crange’: Critical range (float)

  • ’H0’: Test result (bool)

  • ’longitude’: Results of the longitude test as a nested dictionary

    • ’stat’: Test statistic (float)

    • ’crange’: Critical range (float)

    • ’H0’: Test result (bool)

  • ’twovariable’: Results of the two-variable test as a nested dictionary

    • ’stat’: Test statistic (float)

    • ’crange’: Critical range (float)

    • ’H0’: Test result (bool)

  • ’H0’: All three tests retain H0 then True, otherwise false

  • ’alpha’: Type-I error level

4

Fisher, N. I. & Best, D. J. (1984). Goodness-of-fit tests for Fisher’s distribution on the sphere. Austral. J. Statist. 26, 142-150.

sphstat.singlesample.isfishervskent(samplecart: dict, alpha: float = 0.05) dict[source]

Test of whether a sample comes from a Fisher distribution, against the alternative that it comes from a Kent distribution

Parameters
  • samplecart (dict) – Sample to be tested in cart format

  • alpha (float) – Type-I error level

Returns

Dictionary containing the keys: - K: Test statistic (float) - cval: Critical value (float) - p: p-value (float) - testresult: Test result (bool)

Return type

dict

sphstat.singlesample.isuniform(sample: dict, alpha: float = 0.05) dict[source]

Test if the sample comes from a uniform distribution as opposed to a unimodal distribution 5

Parameters
  • sample – Sample to be tested in ‘cart’ format

  • alpha – Type-I error level (e.g. 0.05)

Returns

Dictionary containing the keys - teststat: Test statistic (float) - crange: Critical range (float) - testresult: Test result (bool)

Return type

dict

5

Diggle, P. J., Fisher, N. I. & Lee, A. J. (1985). A comparison of tests of uniformity for spherical data. Austral. J. Statist. 27, 53-59.

sphstat.singlesample.kappatest(samplecart: dict, kappa0: float, alpha: float = 0.05, testtype: str = '!=') dict[source]

Test for specified concentration parameter with unknown population mean

Parameters
  • samplecart (dict) – Sample to be tested in ‘cart’ format

  • kappa0 (float) – Concentration parameter to test against (H0: kappa=kappa0)

  • alpha (float) – Type-I error level

  • testtype – Either on of !=, > or < indicating the sidedness of the test

Returns

Dictionary with the keys: - ‘R’: Test statistics - ‘cvaltup’: Critical value for the test - ‘testresult’: Test result

sphstat.singlesample.kentmeanccone(samplecart: dict, alpha: float = 0.05) tuple[source]

Elliptical confidence cone for the mean direction 6

Parameters
  • samplecart (dict) – Sample to be tested in ‘cart’ format

  • alpha (float) – (1-alpha)% CI is calculated

Returns

  • cconept: 360 points on the (1-alpha)% cone of confidence (list)

  • ths1: Major semi-axis (in radians)

  • ths2: Minor semi-axis (in radians)

Return type

tuple

6

Kent, J. T. (1982). The Fisher-Bingham distribution on the sphere. J.R. Statist. Soc. B 44, 71-80.

sphstat.singlesample.kentparams(samplecart: dict)[source]

Estimation of the parameters of the Kent distribution 7

Parameters

samplecart (dict) – Sample to be tested in ‘cart’ format

Returns

  • ‘axes’: Axes of the distribution (axes[0] is the mean direction)

  • ’kappahat’: Concentration parameter of the distribution (float)

  • ’betahat’: Ovalness parameter (float)

Return type

tuple

7

Kent, J. T. (1982). The Fisher-Bingham distribution on the sphere. J.R. Statist. Soc. B 44, 71-80.

sphstat.singlesample.meanifsymmetric(samplecart: dict, alpha: float = 0.05) tuple[source]

Estimation of the mean direction of a symmetric unimodal distribution 8

Parameters
  • samplecart (dict) – Sample to be tested in ‘cart’ format

  • alpha (float) – Type-I error level

Returns

Dictionary containing the following fields - Spherical mean direction (theta: float, phi: float) - Spherical standard deviation (float) - Semi-vertical angle (float)

Return type

tuple

8

Fisher, N. I. & Lewis, T. (1983). Estimating the common mean direction of several circular or spherical distributions with differing dispersions. Biometrika 70, 333-341.

sphstat.singlesample.meantest(samplecart: dict, mdir0: tuple, alpha: float = 0.05) dict[source]

Test for a specified mean direction

Parameters
  • samplecart (dict) – Sample to be tested in ‘cart’ format

  • mdir0 (tuple) – Mean direction to test against (H0: mdir = mdir0)

  • alpha (float) – Type-I error level

Returns

Dictionary including.. - R: Test statistic (float) - Ralpha: Critical value (float) - testresult: Test result (bool)

Return type

dict

sphstat.singlesample.outliertest(samplecart: dict, alpha: float = 0.05) tuple[source]

Outlier test for discordancy 9

Parameters
  • samplecart (dict) – Sample to be tested in ‘cart’ format

  • alpha (float) – Type-I error level

Returns

  • A new sample with outliers eliminated

  • Index of the outliers in the original sample

Return type

tuple

9

Fisher, N. I., Lewis, T. & Willcox, M. E. (1981). Tests of discordancy for samples from Fisher’s distribution on the sphere. Appl. Statist. 30, 230-237.

sphstat.singlesample.rotationalsymmetry(samplecart: dict, mdir: list, alpha: float = 0.05) dict[source]

Kuiper test for rotational symmetry around the known true mean

Parameters
  • samplecart (dict) – Sample to be tested in ‘cart’ format

  • mdir (list) – Mean direction in polar coordinates (theta, phi)

  • alpha – Type-I error level (e.g. 0.05)

Type

float

Returns

Dictionary containing the following fields… - Test measure: (‘Vnstar’, float) - Critical value: (‘cval’, float) - Test result: (‘res’, bool)

Return type

dict

sphstat.singlesample.testagainstmean(samplecart: dict, tmean: list, alpha: float = 0.05) dict[source]

Test for a specified mean direction of a symmetric distribution 10

Parameters
  • samplecart (dict) – Sample to be tested in ‘cart’ format

  • tmean (np.array) – Mean to be tested against (theta, phi)

  • alpha (float) – Type-I error level

Returns

Dictionary containing the following fields - Test measure (‘hn’, float) - Critical value to test against (‘cval’, float) - Test result (‘testresult’, bool)

10

Watson, G. S. (1983). Statistics on Spheres. University of Arkansas Lecture Notes in the Mathematical Sciences, Volume 6. New York: John Wiley.

sphstat.singlesample.testagainstmedian(sample: dict, tmedi: list, alpha: float = 0.05) dict[source]

Test the null hypothesis that the population has the specified median direction 11

Parameters
  • sample (dict) – Sample to be tested in ‘cart’ format

  • tmedi (array-like) – List containing the polar angles for the specified median

  • alpha (float) – Type-I error level (e.g. 0.05)

Returns

Test measure (X2, float), critical value (cval, float), test result (bool), and significance (p-value, float)

Return type

dict

11

Fisher, N. I. (1985). Spherical medians. J.R. Statist. Soc. B47, 342-348.