Hi all !

I would like to use the Kolmogorov test for a special Gamma distribution :

·         The parameters are estimated from the data,

·         The shift parameter is set to zero.

I thought that the PR #783 would solve the first issue :
https://github.com/openturns/openturns/pull/783

The difference between the distribution I want and ot.Gamma is that ot.Gamma 
has three parameters : shape, scale and shift, while I only want to have 2 
parameters : shape and scale.

I initially planned to use the PythonDistribution in order to create a specific 
Gamma distribution with 2 parameters like this.

import openturns as ot
from openturns.viewer import View

class GammaZeroShift(ot.PythonDistribution):

    def __init__(self, shape=1.0, scale=1.0):
        # shape : k in Gamma
        # scale : lambda in Gamma
        dim = 1
        super().__init__(dim)
        self.shape = shape
        self.scale = scale
        shift = 0.
        self.internalGamma = ot.Gamma(shape,scale,shift)

    def computePDF(self, X):
        return self.internalGamma.computePDF(X)

    def computeCDF(self, X):
        return self.internalGamma.computeCDF(X)

# Create such a distribution
shape = 1.
scale = 5.
mag = ot.Distribution(GammaZeroShift(shape,scale))

View(mag.drawPDF())

The Kolmogorov test goes like this.

# Create a sample from this distribution
samplesize = 1000
threshold = 0.95
sample = mag.getSample(samplesize)

# Use QQ-Plot
qqplot = ot.VisualTest.DrawQQplot(sample, mag)
View(qqplot)

# Use KS test
result = ot.FittingTest.Kolmogorov(sample, mag)
print("P-Value:%f" % (result.getPValue()))
print("Threshold:%f" % (result.getThreshold()))
print("Cannot Reject:%s"% (result.getBinaryQualityMeasure()))


However, this is a wrong approach. When the parameters are estimated from the 
data, the argument of Kolmogorov must be the DistributionFactory, not the 
Distribution itself. This is because the Kolmogorov class must estimate the 
parameters from the data, which is not possible if the distribution is given 
with the parameters already inside.

The problem is : there is no PythonDistributionFactory, isn't it ?

Here would be a potential workaround : would it be possible to create 
parametrized Gamma distribution, by restraining the parameters of the Gamma so 
that the shift parameter is set to zero?

Best regards,

Michaël



Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à 
l'intention exclusive des destinataires et les informations qui y figurent sont 
strictement confidentielles. Toute utilisation de ce Message non conforme à sa 
destination, toute diffusion ou toute publication totale ou partielle, est 
interdite sauf autorisation expresse.

Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le 
copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si 
vous avez reçu ce Message par erreur, merci de le supprimer de votre système, 
ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support 
que ce soit. Nous vous remercions également d'en avertir immédiatement 
l'expéditeur par retour du message.

Il est impossible de garantir que les communications par messagerie 
électronique arrivent en temps utile, sont sécurisées ou dénuées de toute 
erreur ou virus.
____________________________________________________

This message and any attachments (the 'Message') are intended solely for the 
addressees. The information contained in this Message is confidential. Any use 
of information contained in this Message not in accord with its purpose, any 
dissemination or disclosure, either whole or partial, is prohibited except 
formal approval.

If you are not the addressee, you may not copy, forward, disclose or use any 
part of it. If you have received this message in error, please delete it and 
all copies from your system and notify the sender immediately by return message.

E-mail communication cannot be guaranteed to be timely secure, error or 
virus-free.
_______________________________________________
OpenTURNS users mailing list
[email protected]
http://openturns.org/mailman/listinfo/users

Reply via email to