Library

SGSDist.SGSType
SGS(E, b, g)

The stochastically generated skewed (SGS) distribution with parameters E, b and g, derived by Sardeshmukh and Sura (2009) and following the form of Sardeshmukh et al. (2015). The SGS probability density function (pdf) is

\[p(x) = \frac{1}{\mathcal{N}} \left[ \left( Ex + g \right)^{2} + b^{2} \right]^{-\left(1 + \left(1/E^{2}\right)\right)} \mathrm{exp} \! \left[ \frac{2g}{E^{2}b} \mathrm{arctan} \! \left(\frac{Ex + g}{b} \right) \right]\]

where the normalization constant, $\mathcal{N}$, is given as

\[\mathcal{N} = \frac{2 \pi \nu^{1/2} \left( 2b \right)^{-\left(2 \nu + 1 \right)} \Gamma \! \left(2\nu + 1\right)}{\Gamma \! \left( \nu + 1 - iq/2 \right) \Gamma \! \left( \nu + 1 + iq/2 \right)}\]

See also:

Sardeshmukh, P. D., and P. Sura, 2009: Reconciling Non-Gaussian Climate Statistics with Linear Dynamics. Journal of Climate, 22, 1193–1207, https://doi.org/10.1175/2008JCLI2358.1.

Sardeshmukh, P. D., G. P. Compo, and C. Penland, 2015: Need for Caution in Interpreting Extreme Weather Statistics. Journal of Climate, 28, 9166–9187, https://doi.org/10.1175/JCLI-D-15-0020.1.

Examples

julia> d = SGS(0.6236095644623235, 1.1709106481844573, 0.48997894350611143)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)
source
StatsBase.paramsFunction
params(d::SGS)

Return a tuple of SGS parameters E, b and g. Let d be a distribution of type D, then D(params(d)...) will construct exactly the same distribution as $d$.

Examples

julia> d = SGS(0.6236095644623235, 1.1709106481844573, 0.48997894350611143)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> params(d)
(0.6236095644623235, 1.1709106481844573, 0.48997894350611143)
source
Statistics.meanFunction
mean(d::SGS)

Compute the mean of the SGS distribution.

Examples

julia> d = SGS(0.6236095644623235, 1.1709106481844573, 0.48997894350611143)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> mean(d)
0.0
source
Statistics.varFunction
var(d::SGS)

Compute the variance of the SGS distribution.

Examples

julia> d = SGS(0.6236095644623235, 1.1709106481844573, 0.48997894350611143)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> var(d)
1.0
source
SGSDist.stdFunction
std(d::SGS)

Compute the standard deviation of the SGS distribution.

Examples

julia> d = SGS(0.6236095644623235, 1.1709106481844573, 0.48997894350611143)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> std(d)
1.0
source
StatsBase.skewnessFunction
skewness(d::SGS)

Compute the skewness of the SGS distribution.

Examples

julia> d = SGS(0.6236095644623235, 1.1709106481844573, 0.48997894350611143)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> skewness(d)
1.0
source
StatsBase.kurtosisFunction
kurtosis(d::SGS; correction::Bool=true)

Compute the excess kurtosis of the SGS distribution. Excess kurtosis is returned by default with correction=true.

Examples

julia> d = SGS(0.6236095644623235, 1.1709106481844573, 0.48997894350611143)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> kurtosis(d, true)
4.999999999999998
source
Distributions.pdfFunction
pdf(d::SGS, x::Real; norm::Bool=true)

Compute the pdf of the SGS distribution. The SGS pdf is normalized by default, i.e., norm=true. If norm is set to false, then the SGS normalization constant will not be applied.

Here, the SGS probability density function (pdf) is given in the form of Sardeshmukh et al. (2015) as

\[p(x) = \frac{1}{\mathcal{N}} \left[ \left( Ex + g \right)^{2} + b^{2} \right]^{-\left(1 + \left(1/E^{2}\right)\right)} \mathrm{exp} \! \left[ \frac{2g}{E^{2}b} \mathrm{arctan} \! \left(\frac{Ex + g}{b} \right) \right]\]

where the normalization constant, $\mathcal{N}$, is

\[\mathcal{N} = \frac{2 \pi \nu^{1/2} \left( 2b \right)^{-\left(2 \nu + 1 \right)} \Gamma \! \left(2\nu + 1\right)}{\Gamma \! \left( \nu + 1 - iq/2 \right) \Gamma \! \left( \nu + 1 + iq/2 \right)}\]

See also:

Sardeshmukh, P. D., G. P. Compo, and C. Penland, 2015: Need for Caution in Interpreting Extreme Weather Statistics. Journal of Climate, 28, 9166–9187, https://doi.org/10.1175/JCLI-D-15-0020.1.

Examples

julia> d = SGS(0.6236095644623235, 1.1709106481844573, 0.48997894350611143)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> pdf(d, 0.0)
0.46210984589674214
source
pdf(d::SGS, x::AbstractArray; norm::Bool=true)

Compute the pdf of the SGS distribution. The SGS pdf is normalized by default, i.e., norm=true. If norm is set to false, then the SGS normalization constant will not be applied.

Here, the SGS probability density function (pdf) is given in the form of Sardeshmukh et al. (2015) as

\[p(x) = \frac{1}{\mathcal{N}} \left[ \left( Ex + g \right)^{2} + b^{2} \right]^{-\left(1 + \left(1/E^{2}\right)\right)} \mathrm{exp} \! \left[ \frac{2g}{E^{2}b} \mathrm{arctan} \! \left(\frac{Ex + g}{b} \right) \right]\]

where the normalization constant, $\mathcal{N}$, is

\[\mathcal{N} = \frac{2 \pi \nu^{1/2} \left( 2b \right)^{-\left(2 \nu + 1 \right)} \Gamma \! \left(2\nu + 1\right)}{\Gamma \! \left( \nu + 1 - iq/2 \right) \Gamma \! \left( \nu + 1 + iq/2 \right)}\]

See also:

Sardeshmukh, P. D., G. P. Compo, and C. Penland, 2015: Need for Caution in Interpreting Extreme Weather Statistics. Journal of Climate, 28, 9166–9187, https://doi.org/10.1175/JCLI-D-15-0020.1.

Examples

julia> d = SGS(0.6236095644623235, 1.1709106481844573, 0.48997894350611143)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> x = [-0.2, 0.4, 1.5, 5.0]
4-element Array{Float64,1}:
 -0.2
  0.4
  1.5
  5.0

julia> pdf(d, x)
4-element Array{Float64,1}:
 0.4821612875311956
 0.3552310712921366
 0.091209594116695
 0.0011832665173870727

source
Distributions.logpdfFunction
logpdf(d::SGS, x::AbstractArray)

Calculate the log of the probability density function of the SGS distribution.

Examples

julia> d = fit_mm(SGS, 1, 1, 5)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> x = [-10.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0, 5.0]
8-element Array{Float64,1}:
 -10.0
  -1.0
  -0.5
   0.0
   0.5
   1.0
   2.0
   5.0

julia> logpdf(d, x)
8-element Array{Float64,1}:
 -15.504184293152903
  -1.3393373142985014
  -0.8053427806087643
  -0.7719526544799672
  -1.1296521694192523
  -1.7130802377432286
  -3.099847429101194
  -6.739476429937023
source
logpdf(d::SGS, x::Real)

Calculate the log of the cumulative distribution function of the SGS distribution.

Examples

julia> d = fit_mm(SGS, 1, 1, 5)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> x = 0.5
0.5

julia> logpdf(d, x)
-1.1296521694192523
source
Distributions.cdfFunction
cdf(d::SGS, x::AbstractArray)

Calculate the cumulative distribution function of the SGS distribution.

Examples

julia> d = fit_mm(SGS, 1, 1, 5)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> x = [-10.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0, 5.0]
8-element Array{Float64,1}:
 -10.0
  -1.0
  -0.5
   0.0
   0.5
   1.0
   2.0
   5.0

julia> cdf(d, x)
8-element Array{Float64,1}:
 2.7059681332492457e-7
 0.1268532553530455
 0.3074639317904149
 0.5437968749444915
 0.7430905390656029
 0.86706141301943
 0.9654409769867174
 0.9986564347567426
source
cdf(d::SGS, x::Real)

Calculate the cumulative distribution function of the SGS distribution.

Examples

julia> d = fit_mm(SGS, 1, 1, 5)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> x = 0.5
0.5

julia> cdf(d, x)
0.7430905390656029
source
Distributions.logcdfFunction
logcdf(d::SGS, x::AbstractArray)

Calculate the log of the cumulative distribution function of the SGS distribution.

Examples

julia> d = fit_mm(SGS, 1, 1, 5)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> x = [-10.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0, 5.0]
8-element Array{Float64,1}:
 -10.0
  -1.0
  -0.5
   0.0
   0.5
   1.0
   2.0
   5.0

julia> logcdf(d, x)
8-element Array{Float64,1}:
 -15.12263589760972
  -2.064724330254346
  -1.1793974936056804
  -0.6091794935003683
  -0.2969373856106992
  -0.14264547077775455
  -0.035170311051895865
  -0.0013444686363078492
source
logcdf(d::SGS, x::Real)

Calculate the log of the cumulative distribution function of the SGS distribution.

Examples

julia> d = fit_mm(SGS, 1, 1, 5)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> x = 0.5
0.5

julia> logcdf(d, x)
-0.2969373856106992
source
Distributions.ccdfFunction
ccdf(d::SGS, x::AbstractArray)

Calculate the complementary cumulative distribution function of the SGS distribution.

Examples

julia> d = fit_mm(SGS, 1, 1, 5)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> x = [-10.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0, 5.0]
8-element Array{Float64,1}:
 -10.0
  -1.0
  -0.5
   0.0
   0.5
   1.0
   2.0
   5.0

julia> ccdf(d, x)
8-element Array{Float64,1}:
 0.9999997294031867
 0.8731467446469545
 0.6925360682095851
 0.45620312505550853
 0.25690946093439715
 0.13293858698057004
 0.03455902301328262
 0.0013435652432574052
source
ccdf(d::SGS, x::Real)

Calculate the complementary cumulative distribution function of the SGS distribution.

Examples

julia> d = fit_mm(SGS, 1, 1, 5)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> x = 0.5
0.5

julia> ccdf(d, x)
0.25690946093439715
source
Distributions.logccdfFunction
logccdf(d::SGS, x::AbstractArray)

Calculate the log of the complementary cumulative distribution function of the SGS distribution.

Examples

julia> d = fit_mm(SGS, 1, 1, 5)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> x = [-10.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0, 5.0]
8-element Array{Float64,1}:
 -10.0
  -1.0
  -0.5
   0.0
   0.5
   1.0
   2.0
   5.0

julia> logccdf(d, x)
8-element Array{Float64,1}:
 -2.70596849901216e-7
 -0.1356516448893756
 -0.3673949582198083
 -0.7848171189678753
 -1.3590315482404094
 -2.017868009426468
 -3.365086604737457
 -6.612428568931222
source
logccdf(d::SGS, x::Real)

Calculate the log of the complementary cumulative distribution function of the SGS distribution.

Examples

julia> d = fit_mm(SGS, 1, 1, 5)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> x = 0.5
0.5

julia> logccdf(d, x)
-1.3590315482404094
source
StatsBase.fitFunction
fit(d::Type{SGS}, x::AbstractArray)

Fit an SGS distribution to the time series, x.

Examples

julia> fit(SGS, air())
SGS{Float64}(E=0.36623331624359673, b=0.7133796999284913, g=-1.1648873051087967)
source
fit(d::Type{SGS}, variance::Real, skew::Real, kurt::Real)

Fit an SGS distribution to the desired variance, skewness and kurtosis.

Examples

julia> fit(SGS, 1.0, 1.0, 5.0)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)
source
SGSDist.CAM1DFunction
CAM1D(d::SGS, n::Integer; dt::Real=1/24, λ::Real=1.0)

Create a timeseries using the one-dimensional CAM noise model of Sardeshmukh and Sura (2009) for a particular SGS distribution.

See also:

Sardeshmukh, P. D., and P. Sura, 2009: Reconciling Non-Gaussian Climate Statistics with Linear Dynamics. Journal of Climate, 22, 1193–1207, https://doi.org/10.1175/2008JCLI2358.1.

Sardeshmukh, P. D., G. P. Compo, and C. Penland, 2015: Need for Caution in Interpreting Extreme Weather Statistics. Journal of Climate, 28, 9166–9187, https://doi.org/10.1175/JCLI-D-15-0020.1.

Examples

julia> d = fit(SGS, 1, 1, 5)
SGS{Float64}(E=0.6236095644623235, b=1.1709106481844573, g=0.48997894350611143)

julia> x = CAM1D(d, 1000, seed=42)
retcode: Success
Interpolation: 1st order linear
t: 1001-element Array{Float64,1}:
  0.0
  0.041666666666666664
  0.08333333333333333
  0.125
  0.16666666666666666
  0.20833333333333331
  0.24999999999999997
  0.29166666666666663
  0.3333333333333333
  0.375
  ⋮
 41.333333333333165
 41.37499999999983
 41.416666666666494
 41.45833333333316
 41.49999999999982
 41.54166666666649
 41.58333333333315
 41.624999999999815
 41.625
u: 1001-element Array{Array{Float64,1},1}:
 [0.0]
 [-0.05538507236046931]
 [0.3759078513765659]
 [0.31482891888314446]
 [0.2586995978771358]
 [0.0063144005340343146]
 [0.0819076515551697]
 [0.07880240481554046]
 [-0.09903540075387843]
 [-0.0867782526753085]
 ⋮
 [-0.048583800782025996]
 [0.30770620643597935]
 [0.6914165604620269]
 [1.2048828846162343]
 [0.6995798768325538]
 [0.5417553247799438]
 [0.593919650292867]
 [0.6785936302181321]
 [0.6785940957553152]
source
SGSDist.Hasselmann1DFunction
Hasselmann1D(n::Integer; dt::Real=1/24, λ::Real=1.0, seed::Real=-1)

Create a timeseries using the one-dimensional noise model of Hasselmann (1976).

See also:

Hasselmann, K., 1976: Stochastic climate models Part I. Theory. Tellus, 28, 473–485, https://doi.org/10.1111/j.2153-3490.1976.tb00696.x.

Examples

julia> Hasselmann1D(1000, seed=42)
retcode: Success
Interpolation: 1st order linear
t: 1001-element Array{Float64,1}:
  0.0
  0.041666666666666664
  0.08333333333333333
  0.125
  0.16666666666666666
  0.20833333333333331
  0.24999999999999997
  0.29166666666666663
  0.3333333333333333
  0.375
  ⋮
 41.333333333333165
 41.37499999999983
 41.416666666666494
 41.45833333333316
 41.49999999999982
 41.54166666666649
 41.58333333333315
 41.624999999999815
 41.625
u: 1001-element Array{Array{Float64,1},1}:
 [0.0]
 [-0.13005535542166108]
 [0.04828669603525988]
 [0.658691166050971]
 [0.4766431404349038]
 [0.2527905702593073]
 [0.5063085613562422]
 [0.4424101651546515]
 [0.42457583766050366]
 [0.17019337828909467]
 ⋮
 [0.04255470162528974]
 [-0.009396010196968833]
 [-0.4700188956712661]
 [-0.6640224731670598]
 [-0.6412697125734018]
 [-0.8226707386234939]
 [-0.9240097641730844]
 [-0.3550868399241892]
 [-0.35508653697280324]
source
Base.randFunction
rand(d::SGS)

Generate a scalar sample from the SGS distribution d.

source
rand(d::SGS, n::Int64)

Generate an array of n samples from the SGS distribution d.

source
rand(d::SGS)

Generate a scalar sample from the SGS distribution d.

source
rand(rng::AbstractRNG, d::SGS, n::Int64)

Generate an array of n samples from the SGS distribution d.

source
SGSDist.airFunction
air()

Produce an array of sample climate data for testing. This sample time series is taken from the NCEP/NCAR Reanalysis 1 dataset, representing the 925 hPa air temperature standardized anomalies of all DJF winters from 1948-2018 at 50.0°N, 235.0°E.

See also:

Kalnay, E., and Coauthors, 1996: The NCEP/NCAR 40-year reanalysis project. Bulletin of the American Meteorological Society, 77, 437–471, https://doi.org/10.1175/1520-0477(1996)077<0437:TNYRP>2.0.CO;2.

Examples

julia> air()
6408-element Array{Float64,1}:
  0.67547214
  0.8308915
  0.19012427
 -0.20711477
 -0.10181273
  0.7421673
  0.22026125
  0.050515447
  0.043254483
  0.044615462
  ⋮
  0.7591071
  0.54696834
  0.3421846
  0.044188347
  0.2433472
  0.4460243
  1.4941149
  0.49388295
 -0.052520715
source