mbaudin47 / othdrplot

High density plot
GNU Lesser General Public License v3.0
2 stars 3 forks source link

Graphs from OT #4

Closed tupui closed 5 years ago

tupui commented 5 years ago

Replace matplotlib graphs with OT.

Closes #2

tupui commented 5 years ago

I will add another commit to replace other mpl graphs. My concern is around the use of the ot.Graph object. I am not sure I am using it properly in the tests.

tupui commented 5 years ago

The graphs are now done using OT except for the fill_between which is still some mpl. It seems that we could do that using ot.Polygon. @mbaudin47 What do you think?

tupui commented 5 years ago

I also made an attempt for the computation of the mean using the distribution. The mean is found as the curve which produce the max PDF value.

@mbaudin47 Do we need to try to do an optimization to find the mean based on the KDE? If yes, using which optimization method from OT?

tupui commented 5 years ago

As a side note, the API for the Graphs (in OpenTURNS) is not consistent. For Contour, Pairs or Cloud the order of common arguments is not the same.

mbaudin47 commented 5 years ago

I also made an attempt for the computation of the mean using the distribution. The mean is found as the curve which produce the max PDF value. @mbaudin47 Do we need to try to do an optimization to find the mean based on the KDE? If yes, using which optimization method from OT?

My plan for the ProcessHDRAlgo is to first separate the core of the estimation of the density algorithm from the code so that we can use an alternative to KDE, e.g. a gaussian mixture. Afterwards, we might better see which option can be used for any density estimate, rather than focus on potential properties of the KDE. On your specific question, my guess is that any optimizer should do the trick, but a gradient based method should perform best: this should be easy in theory, given that a density has its gradients and that KDE is by construction a regular function. My best option would be NLOPT/LD_LBFGS, but the doc seems to require bounds on the parameters, which is not appropriate here: this seems to require more experiments.

mbaudin47 commented 5 years ago

Here is a subplot example which might be interesting in order to be combined with a Contour in the general case where dim>2.

import openturns as ot
import pylab as pl

myBeta = ot.Beta(5, 7, 9, 10)
myPDFBeta = myBeta.drawPDF()
myCDFBeta = myBeta.drawCDF()
myExponential = ot.Exponential(3)
myPDFExp = myExponential.drawPDF()
myCDFExp = myExponential.drawCDF()

fig = pl.figure(figsize=(12, 4))
ax_pdf = fig.add_subplot(2, 2, 1)
_ = ot.viewer.View(myPDFBeta, figure=fig, axes=[ax_pdf])
ax_cdf = fig.add_subplot(2, 2, 2)
_ = ot.viewer.View(myCDFBeta, figure=fig, axes=[ax_cdf])
ax_pdf_exp = fig.add_subplot(2, 2, 3)
_ = ot.viewer.View(myPDFExp, figure=fig, axes=[ax_pdf_exp])
ax_cdf_exp = fig.add_subplot(2, 2, 4)
_ = ot.viewer.View(myCDFExp, figure=fig, axes=[ax_cdf_exp])

image