How to create a weibullgpd distribution?

Hello,

I want to create a weibullgpd distribution as defined (for R) on the website weibullgpd function - RDocumentation.

Is it possible to do it with OpenTURNS ? If so, can you tell me how please ?

Thank you,
Alexis

Hi,
Sorry for answering you so late. Using OpenTURNS, you can truncated distributions and build mixtures, which makes it easy to emulate the weibullgpd distribution:

import openturns as ot
from math import sqrt

def BuildWeibullGPD(wshape=1.0, wscale=1.0, u=ot.WeibullMin(1.0, 1.0).computeQuantile(0.9)[0], sigmau=None, xi=0.0, phiu=None):
    H = ot.WeibullMin(wscale, wshape)
    Ht = ot.TruncatedDistribution(H, 0.0, u)
    if sigmau is None:
        sigmau = sqrt(wscale**2 * ot.SpecFunc.Gamma(1.0 + 2.0 / wshape) - (wscale * ot.SpecFunc.Gamma(1.0 + 1.0 / wshape))**2)
    if phiu is None:
        phiu = H.computeComplementaryCDF(u)
    G = ot.GeneralizedPareto(sigmau, xi, u)
    return ot.Mixture([Ht, G], [1.0 - phiu, phiu])

xx = ot.RegularGrid(-1.0, 0.1, 71).getVertices()
print("xx=", xx)
d = BuildWeibullGPD(xi=0.0)
print("d=", d.computePDF(xx))
d = BuildWeibullGPD(xi=-0.2)
print("d=", d.computePDF(xx))
d = BuildWeibullGPD(xi=0.2)
print("d=", d.computePDF(xx))
d = BuildWeibullGPD(xi=0.0, phiu=0.2)
print("d=", d.computePDF(xx))
d = BuildWeibullGPD(xi=-0.2, phiu=0.2)
print("d=", d.computePDF(xx))
d = BuildWeibullGPD(xi=0.2, phiu=0.2)
print("d=", d.computePDF(xx))

You should double check it, but it gives me the same results as the following R script:

library(evmix)
xx = seq(-1, 6, 0.1)
print(xx)
print(dweibullgpd(xx, xi = 0.0))
print(dweibullgpd(xx, xi =-0.2))
print(dweibullgpd(xx, xi = 0.2))
print(dweibullgpd(xx, xi = 0.0, phiu = 0.2))
print(dweibullgpd(xx, xi =-0.2, phiu = 0.2))
print(dweibullgpd(xx, xi = 0.2, phiu = 0.2))

Cheers

Régis

Hi Régis,
Thank you very much, it seems to work perfectly !

Best regards,
Alexis