Package 'distTails'

Title: A Collection of Full Defined Distribution Tails
Description: A full definition for Weibull tails and Full-Tails Gamma and tools for fitting these distributions to empirical tails. This package builds upon the papers by del Castillo, Joan & Daoudi, Jalila & Serra, Isabel. (2012) <doi: 10.1017/asb.2017.9> and Vilardell, Sergi & Serra, Isabel & Abella, Jaume & del Castillo, Joan & Cazorla, Francisco. (2019). Software Timing Analysis for Complex Hardware with Survivability and Risk Analysis. 227-236. <doi: 10.1109/ICCD46524.2019.00036>. This work has been supported by the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation programme (grant agreement No. 772773).
Authors: Sergi Vilardell [aut, cre], Àlvar Pineda [aut]
Maintainer: Sergi Vilardell <[email protected]>
License: GPL-3
Version: 1.0.0
Built: 2025-03-07 03:33:13 UTC
Source: https://github.com/sergivilardell/disttails

Help Index


FTG Density Function

Description

This function computes the density of the full-tail gamma with the input sample data. The expression for the density used is:

g(x;α,θ,ρ)=ρασ(ρ+xσ)α1exp((ρ+xσ))/Γ(α,ρ).g(x; \alpha, \theta, \rho) = \frac{\rho^{\alpha}}{\sigma}\left(\rho + \frac{x}{\sigma}\right)^{\alpha - 1}\exp\left(-\left(\rho + \frac{x}{\sigma}\right)\right)/\Gamma(\alpha, \rho).

Usage

dFTG(x, threshold, scale, shape)

Arguments

x

Sample data.

threshold

Minimum value of the tail.

scale

Scale parameter.

shape

Shape parameter.

Value

Gives the density of the FTG. The length of the result is determined by the length of x.

References

del Castillo, Joan & Daoudi, Jalila & Serra, Isabel. (2012). The full-tails gamma distribution applied to model extreme values. ASTIN Bulletin. <doi:10.1017/asb.2017.9>.

Examples

a <- 0.3
t <- 0.3
r <- 0.8
n <- 1000
sample <- rFTG(n, a, t, r)
x <- seq(min(sample), max(sample), length.out = 200)
d <- dFTG(x, a, t, r)
hist(sample, breaks = "FD", probability = TRUE)
lines(x, d, col = "red")

TailW Density function

Description

This function computes the density of the tailW with the input sample data. The expression for the density used is:

f(x,α,β,ν)=αβ(x+ν)β1exp(α(x+ν)β+ανβ)f(x, \alpha, \beta, \nu) = \alpha \beta (x + \nu)^{\beta -1} \exp(-\alpha(x + \nu)^{\beta} + \alpha \nu^{\beta})

Usage

dtailw(x, threshold, scale, shape)

Arguments

x

Sample data.

threshold

Minimum value of the tail.

scale

Scale parameter.

shape

Shape parameter.

Value

Gives the density of the TailW. The length of the result is determined by the length of x.

References

Vilardell, Sergi & Serra, Isabel & Abella, Jaume & del Castillo, Joan & Cazorla, Francisco. (2019). Software Timing Analysis for Complex Hardware with Survivability and Risk Analysis. 227-236. <doi:10.1109/ICCD46524.2019.00036>.

Examples

# Generate random deviates from a weibull tail and plot the theoretical density.
scale <- 2
shape <- 1
threshold <- 1
x_seq <- seq(threshold, 5, length.out = 500)
theo_density <- dtailw(x_seq, threshold = threshold, scale = scale, shape = shape)
sample <- rtailw(500, threshold = threshold, scale = scale, shape = shape)
hist(sample, probability = TRUE)
lines(x = x_seq, y = theo_density, col = "red")

TailW Maximum Likelihood Estimation

Description

Maximum Likelihood Estimation of the tails by fitting a tailW or a FTG.

Usage

fittail(sample, dist = "TailW")

Arguments

sample

Sample data.

dist

Name of the distribution to fit.

Value

Gives a list of the estimated parameters fo the function fitted. For the TailW it returns, scale and shape. Fot the FTG it returns the parameters scale, shape, and threshold.

Examples

scale <- 2
shape <- 1
threshold <- 1
s <- rtailw(1000, threshold = threshold , scale = scale, shape = shape)
fits <- fittail(s, dist = "TailW")
x_seq <- seq(threshold, max(s), length.out = 500)
theo_density <- dtailw(x_seq, threshold = threshold, scale = fits$scale, shape = fits$shape)
hist(s, probability = TRUE, breaks = "FD")
lines(x = x_seq, y = theo_density, col = "red")

FTG Log-likelihood Function

Description

This function computes the loglikelihood of the full-tail gamma with the input sample data. The expression used is:

l(x;α,σ,ρ)=n(logΓ(α,ρ)+log(σ)αlog(ρ)α1ni=1nlog(1+xiσ)+ρni=1n(1+xiσ))l(x; \alpha, \sigma, \rho) = -n\left(\log\Gamma(\alpha, \rho) + \log(\sigma) -\alpha \log(\rho) - \frac{\alpha - 1}{n}\sum_{i = 1}^{n}\log\left(1 + \frac{x_{i}}{\sigma}\right) + \frac{\rho}{n} \sum_{i = 1}^{n}\left(1 + \frac{x_{i}}{\sigma}\right)\right)

Usage

lFTG(x, threshold, scale, shape)

Arguments

x

Sample data.

threshold

Minimum value of the tail.

scale

Scale parameter.

shape

Shape parameter.

Value

Gives the log-likelihood of the FTG. The length of the result is determined by the length of x.

References

del Castillo, Joan & Daoudi, Jalila & Serra, Isabel. (2012). The full-tails gamma distribution applied to model extreme values. ASTIN Bulletin. <doi:10.1017/asb.2017.9>.

Examples

lFTG(1,1,1,1)

TailW Log-likelihood function

Description

This function computes the log-likelihood of the tailW with the input sample data.

l(x;α,β)=n(log(α)+log(β))+(β1)i=1nlog(x+ν)αi=1n((x+ν)βνβ)l(x;\alpha,\beta) = n(\log(\alpha)+\log(\beta))+(\beta-1)\sum_{i=1}^{n}\log(x+\nu)-\alpha\sum_{i=1}^{n}((x+\nu)^\beta-\nu^\beta)

Usage

ltailw(x, threshold, scale, shape)

Arguments

x

Sample data.

threshold

Minimum value of the tail.

scale

Scale parameter.

shape

Shape parameter.

Value

Gives the log-likelihood of the TailW. The length of the result is determined by the length of x.

References

Vilardell, Sergi & Serra, Isabel & Abella, Jaume & del Castillo, Joan & Cazorla, Francisco. (2019). Software Timing Analysis for Complex Hardware with Survivability and Risk Analysis. 227-236. <doi:10.1109/ICCD46524.2019.00036>.

Examples

ltailw(1,1,1,1)

FTG Probability Function

Description

This function computes the probability of the full-tail gamma with the input sample data. The expression for the probability used is:

G(x;α,θ,ρ)=1Γ(α,ρ(1+xσ))/Γ(α,ρ).G(x; \alpha, \theta, \rho) = 1 - \Gamma\left(\alpha, \rho\left(1 + \frac{x}{\sigma}\right)\right)/\Gamma(\alpha, \rho).

Usage

pFTG(x, threshold, scale, shape)

Arguments

x

Sample data.

threshold

Minimum value of the tail.

scale

Scale parameter.

shape

Shape parameter.

Value

Gives the distribution function of the FTG. The length of the result is determined by the length of x.

References

del Castillo, Joan & Daoudi, Jalila & Serra, Isabel. (2012). The full-tails gamma distribution applied to model extreme values. ASTIN Bulletin. <doi:10.1017/asb.2017.9>.

Examples

pFTG(1,1,1,1)

TailW Probability Function

Description

This function computes the cumulative density function of the tailW with the input sample data.

F(x,α,β,ν)=1exp(α(x+ν)β+ανβ).F(x,\alpha,\beta,\nu)=1-\exp(-\alpha(x+\nu)^\beta+\alpha\nu^\beta).

Usage

ptailw(x, threshold, scale, shape)

Arguments

x

Sample data.

threshold

Minimum value of the tail.

scale

Scale parameter.

shape

Shape parameter.

Value

Gives the distribution function of the TailW. The length of the result is determined by the length of x.

References

Vilardell, Sergi & Serra, Isabel & Abella, Jaume & del Castillo, Joan & Cazorla, Francisco. (2019). Software Timing Analysis for Complex Hardware with Survivability and Risk Analysis. 227-236. <doi:10.1109/ICCD46524.2019.00036>.

Examples

# Using the probability function to show the fitting.
samp <- rtailw(1000, 1, 2, 3)
emp_cdf <- ecdf(samp)(samp)
pars <- fittail(samp, dist = "TailW")
x_seq <- seq(min(samp), max(samp), length.out = 250)
p <- ptailw(x_seq, threshold = 1, scale = pars$scale, shape = pars$shape)
plot(samp, 1-emp_cdf, log = "y")
lines(x_seq, 1-p, col = "red")

FTG Quantile function

Description

This function computes the quantiles of the full-tail gamma with the input sample data.

Usage

qFTG(p, threshold, scale, shape, interval)

Arguments

p

Probability.

threshold

Minimum value of the tail.

scale

Scale parameter.

shape

Shape parameter.

interval

a vector containing the end-points of the interval to be searched for the minimum.

Value

Gives the quantiles of the FTG. The length of the result is determined by the length of x.

References

del Castillo, Joan & Daoudi, Jalila & Serra, Isabel. (2012). The full-tails gamma distribution applied to model extreme values. ASTIN Bulletin. <doi:10.1017/asb.2017.9>.

Examples

qFTG(0.5,1,1,1, c(0,10))

Quantile function

Description

This function computes the quantile function of the tailW.

Q(p,α,β,ν)=(log(1p)α+νβ)1/βQ(p,\alpha, \beta, \nu) = \left(\frac{-\log(1 - p)}{\alpha} + \nu^\beta\right)^{1 / \beta}

Usage

qtailw(p, threshold, scale, shape)

Arguments

p

Probability.

threshold

Minimum value of the tail.

scale

Scale parameter.

shape

Shape parameter.

Value

Gives the quantiles of the TailW. The length of the result is determined by the length of x.

References

Vilardell, Sergi & Serra, Isabel & Abella, Jaume & del Castillo, Joan & Cazorla, Francisco. (2019). Software Timing Analysis for Complex Hardware with Survivability and Risk Analysis. 227-236. <doi:10.1109/ICCD46524.2019.00036>.

Examples

qtailw(0.5, 1, 1, 1)

FTG Random Sample Generation

Description

This function computes n random variates from full-tail gamma with a rejection method.

Usage

rFTG(n, threshold, scale, shape)

Arguments

n

Sample size.

threshold

Minimum value of the tail.

scale

Scale parameter.

shape

Shape parameter.

Value

Gives random deviates of the FTG. The length of the result is determined by n.

References

del Castillo, Joan & Daoudi, Jalila & Serra, Isabel. (2012). The full-tails gamma distribution applied to model extreme values. ASTIN Bulletin. <doi:10.1017/asb.2017.9>.

Examples

x <- rFTG(100, 1, 1, 1)
hist(x, breaks = "FD")

TailW Random Sample Generation

Description

This function generates random deviates for the tailW distribution.

Usage

rtailw(n, threshold, scale, shape)

Arguments

n

Sample size.

threshold

Minimum value of the tail.

scale

Scale parameter.

shape

Shape parameter.

Value

Gives random deviates of the TailW. The length of the result is determined by n.

References

Vilardell, Sergi & Serra, Isabel & Abella, Jaume & del Castillo, Joan & Cazorla, Francisco. (2019). Software Timing Analysis for Complex Hardware with Survivability and Risk Analysis. 227-236. <doi:10.1109/ICCD46524.2019.00036>.

Examples

x <- rtailw(1000, 1, 2, 3)
hist(x, breaks = "FD")