NCL Home > Documentation > Functions > General applied math, Statistics

cohsq_c2p

Given coherence-squared and the effective degrees-of-freedom, calculate the associated probability.

Available in version 6.4.0 and later.

Prototype

```load "\$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"  ; This library is automatically loaded
; from NCL V6.2.0 onward.
; No need for user to explicitly load.

function cohsq_c2p (
cohsq  : numeric,  ; float or double
edof   : numeric
)

return_val  :  An array of the same size, shape and shape  as cohsq.
```

Arguments

cohsq

A scalar or array containing coherence-squared values (0 to 1.0)

edof

A scalar or array containing the effective degrees-of-freedom. If an array, it must match the size and shape as cohsq.

Return value

Numeric (float or double) array containing probabilities of the same size and shape as cohsq.

Description

The coherence-squared is a statistic that can be used to examine the degree of linear association between two series. It allows identification of significant frequency-domain correlation between the two time series. It is analogous to the coefficient of determination (square of the correlation coefficient) between two series.

NOTE: Phase estimates in the cross spectrum are only useful where significant frequency-domain correlation exists.

NCL's specxy_anal returns the total (FFT-based) degrees of freedom. The effective degrees-of-freedom (edof) is half that number. (See Example 4)

```References:

Data Analysis Methods in Physical Oceanography /
William J. Emery; Thomson, Richard E.
Elsevier, 2001 (2nd Edition); ISBN: 0444507566 (hardbound); 0444507574 (paperback).

Course Notes
Dennis Hartmann (Univ. Washington)
See Table 6.2 , page 187 and the associated caption on page 186

Comments on the Determination of Significance Levels of the Coherence Statistic
Paul R. Julian
J. of Atm. Sci. (1975), Volume 32, pp 836-837.

Coherence Significance Levels
Rory O. R. Y. Thompson
Journal of the Atmospheric Sciences, 1979
Volume 36, pp 2020-2021

-------------------------------------------------------------------------------
Tables of the Distribution of the Coefficient of Coherence
for Stationary Bivariate Gaussian Processes
Amos, D.  E., and L.  H.  Koopmans (1963)
Washington, Office of Technical  Services, Dept.  of Commerce.

On the Joint Estimation of the Spectra, Cospectrum and Quadrature Spectrum of a
Two-dimensional Stationary Gaussian Process
Goodman, N.R. (1957)
New York University
```

Examples

The following match the numbers of Hartmann's Table 6.2. Note: The examples use nice round degrees of freedom but, they may be fractional (eg: 20.37):

Example 1: Both coherence-squared and edof are scalars

```    c2   = 0.283
edof = 10
p    = cohsq_c2p(c2, edof)    ; p=0.95
```

Example 2: The coherence-squared is an array and edof is a scalar:

```    c2   = (/0.036, 0.112, 0.146, 0.215, 0.305 /)                     ; c2(5)
edof = 20                                                         ; scalar
p    = cohsq_c2p(c2, edof)    ; p(5) ==> (/0.50, 0.90, 0.95, 0.99, 0.999 /)
```

Example 3: Both coherence-squared and edof are arrays which have the same shape and size:

```    c2   = (/0.159, 0.226, 0.146, 0.090, 0.068 /)                     ; c2(5)
edof = (/  5  ,  10  ,  20  ,  50  ,  100  /)                     ; edof(5)
p    = cohsq_c2p(c2, edof)    ; p(5) ==> (/0.50, 0.90, 0.95, 0.99, 0.999 /)
```

Example 4: Calculate the probability level of each coherence-squared returned by specxy_anal.

```    d      = 0                    ; detrending opt: 0=>remove mean 1=>remove mean and detrend
sm     = 7                    ; smoothing periodogram: should be at least 3 and odd
pct    = 0.10                 ; percent tapered: 0.10 common.

; calculate the cross-spectrum
sxydof = specxy_anal(x,y,d,sm,pct)   ; sdof is a scalar quantity
printVarSummary(sxydof)     ; look at the returned variable

edof   = sxydof/2             ; effective degrees of freedom

c2     = spec@coher           ; c2(N)
p      = cohsq_c2p(c2, edof)  ; p(N)

print(sprintf("%6.3f", c2) +"  "+ sprintf("%6.3f", p) )
```