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

# taylor_stats

Calculates statistics needed for the Taylor Diagram: pattern_correlation, ratio and bias. Available in version 6.5.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 taylor_stats (
t [*][*] : numeric,
r [*][*] : numeric,
w        : numeric,
opt   : integer
)

return_val  or  :  float or double
```

## Arguments

t

Test array. The array is expected to be (nominally) shaped as (ny,nx) or (nlat,mlon).

r

Reference array. This must be the same size, shape and ordering as (t).

w

A scalar, or array containing the spatial weights to be used.

• if w (eg, 1.0) then all (t) and (r) values will get the same weight. The effect is no spatial weighting.
• if w[*], then the t and t the arrays are rectilinear.
• if w[*][*], then the t and r the arrays are curvilinear.

opt

Integer flag indicating which values should be returned. In each case, the return is a one-dimensional array:

• iopt=0: (/pattern_correlation,ratio, bias/)
• iopt=1: (/pattern_correlation,ratio, bias, tmean, rmean, tvar, rvar, rmse /)
• tmean, rmean: area weighted means
• tvar, rvar: area weighted variances
• rmse: area weighted mean root-mean-square error grid-point differences

## Description

For the classic Taylor Diagram (Taylor, 2005), the pertinent statistics are the weighted centered pattern correlation(s) (pattern_cor) and the ratio(s) of the normalized root-mean-square (RMS) differences between 'test' dataset(s) and 'reference' dataset(s). An additional bias statistic, may be added to the classic Taylor Diagram. The pattern_corrrelations and ratios are calculated as described in the references. The bias is calculated as follows:

```   bias = 100*(mean_test - mean_reference)/mean_reference)    ; bias [%]
```
Taylor diagram examples 7b and 8 show the bias being plotted.

Reference:

```   Taylor, K.E. (2001):  Summarizing multiple aspects of model performance in a single diagram
JGR, vol 106, no. D7, 7183-7192, April 16, 2001.

Taylor, K.E. (2005):  Taylor Diagram Primer
A brief 4-page overview which summarizes the important aspects of these useful plots.
```

## Examples

See: Taylor diagram examples 7 and 8. These illustrate handling multiple variables and cases.

Example 1: Let X(nlat,mlon) and R(nlat,mlon) represent (say) climatologies and be on rectilinear grids.

```      ;w = 1.0             ; scalar     ==> no weighting
w = gwt             ; gw(nlat)   ==> gaussian weights
;w = clat            ; clat(nlat) ==> cos(rad*lat)

tay_stat = taylor_stats(X, R, w, 0)  ; tay_stat(3)
tay_stat = taylor_stats(X, R, w, 1)  ; tay_stat(8)
```

Example 2: Let X(nlat,mlon) and R(nlat,mlon) represent (say) an ensemble member and a reference field on curvilinear grid.

```      ;w = 1.0             ; scalar          ==> no weighting
w = area            ; area(nlat,mlon)
;w = clat            ; clat(nlat,mlon) ==> cos(rad*lat2d)

tay_stat = taylor_stats(X, R, w, 0)  ; tay_stat(3)
tay_stat = taylor_stats(X, R, w, 1)  ; tay_stat(8)
```