Probability Density Function

62 views
Skip to first unread message

Anne Queentina

unread,
Aug 22, 2017, 2:39:55 AM8/22/17
to OpendTect Developers
Hi All,

I want to change the function of probability density function in Opendtect, from Gaussian to Kernel.
Is anyone have solution?

Regards,
Anne Queentina

Bert Bril

unread,
Aug 22, 2017, 8:44:30 AM8/22/17
to devel...@opendtect.org
Hi Anne,


> I want to change the function of probability density function in
> Opendtect, from Gaussian to Kernel.

It's going to be a lot of programming, partly in the core OpendTect classes.

First of all you need to make a subclasses of ProbDenFunc that works.
The easiest way to go about is to look at how it's done for the Gaussian
PDF's (Algo/gaussianprobdenfunc.h and .cc).

Once you have that implemented you'll have to modify the UI classes in
uiIo (for example uiEditPDF). Currently, OpendTect only recognises two
types: Gaussian and Sampled. There is no factory. So you'll have to
adapt the OpendTect base code.


Maybe the best thing to do is to have user specify the parameters of
your PDF, then generate a Sampled PDF from that. That could be a quite
simple implementation path that can be done from a plugin.


/Bert

Anne Queentina

unread,
Aug 28, 2017, 3:29:53 AM8/28/17
to Bert Bril, devel...@opendtect.org
Dear Mr. Bert Bril,

Thank you for your suggestion. I have tried to coding in gaussianprobdenfunc.cc(float Gaussian2DProbDenFunc::gtVal(float p0, float p1) const). I changed the parameters and succeed.
Inline image 1

But, when I run the Opendtect, there was no significant changes in the result of probability density function(PDF). Usually, I made seismic cubes from the result of PDFs using Bayesian Classification too, but the value is undefined. Could you tell me, what's wrong and what should I do?
Inline image 3

For your information, cross-plot attribute vs well data are used to make PDFs.

Regards,
Anne Queentina

On Tue, Aug 22, 2017 at 8:39 PM, Bert Bril <bert...@dgbes.com> wrote:
Hi Anne,


I want to change the function of probability density function in Opendtect, from Gaussian to Kernel.

It's going to be a lot of programming, partly in the core OpendTect classes.

First of all you need to make a subclasses of ProbDenFunc that works. The easiest way to go about is to look at how it's done for the Gaussian PDF's (Algo/gaussianprobdenfunc.h and .cc).

Once you have that implemented you'll have to modify the UI classes in uiIo (for example uiEditPDF). Currently, OpendTect only recognises two types: Gaussian and Sampled. There is no factory. So you'll have to adapt the OpendTect base code.


Maybe the best thing to do is to have user specify the parameters of your PDF, then generate a Sampled PDF from that. That could be a quite simple implementation path that can be done from a plugin.


/Bert



--
Yours sincerely

Anne Queentina Tyas Primasty
Mobile : +628170107515

Bert Bril

unread,
Aug 28, 2017, 4:42:10 AM8/28/17
to devel...@opendtect.org, Anne Queentina
Hi Anne,


> Thank you for your suggestion. I have tried to coding in
> gaussianprobdenfunc.cc(float Gaussian2DProbDenFunc::gtVal(float p0,
> float p1) const). I changed the parameters and succeed.

Not sure why you commented out the old code. Very useful would be to see
the difference. Code like:


if ( cc_ > 1 - 1e-6f )
retval_old = 0;
else
{
const float x1 = (p0 - exp0_) / std0_;
const float x2 = (p1 - exp1_) / std1_;
const float onemccsq = 1 - cc_*cc_;

const float fac = (float)(0.5 / (M_PI*Math::Sqrt(onemccsq)));
const float epow = -0.5f * (x1*x1 + x2*x2 - 2*cc_*x1*x2)
/ onemccsq;
retval_old = fac * Math::Exp( epow );
}

int N = 1000; // Magic number?
const float prodstds = std0_ * std1_;
const float fac = (float)(0.5 / (M_PI*Math::Sqrt(prodstds)*N));
const float epow = -1.0f * (p0 + p1) / prodstds;
retval_new = fac * Math::Exp( epow );

// For example, see if there are significant differences
const float diff = retval_old - retval_new;
if ( diff > some_cutoff_value )
{ /* I can now break here */ }

return retval_new;



> But, when I run the Opendtect, there was no significant changes in the
> result of probability density function(PDF). Usually, I made seismic
> cubes from the result of PDFs using Bayesian Classification too, but the
> value is undefined. Could you tell me, what's wrong and what should I do?

I can not tell you what is wrong, you have to analyze the situation.
Nobody can do that for you, it's part of your life as a software developer.

The tip here is: Routinely check everything you do at where things
originate, not at the end result. 'Run and see what you get' is a proven
bad way of QC-ing your work.


Good luck,

Bert

--

Bert Bril
Coach/Consultant Software Development
_________________________________________________

dGB Earth Sciences

Phone: +31 53 4315155
E-mail: bert...@dgbes.com
Internet: http://dgbes.com & http://opendtect.org

<<SEG Distinguished Achievement Award 2016>>
_________________________________________________

Anne Queentina

unread,
Aug 31, 2017, 4:44:46 AM8/31/17
to Bert Bril, devel...@opendtect.org
Dear Mr. Bert Bril,

Thank you for your response regarding the programming in gaussianprobdenfunc.cc.
In additional, I want to know which part of source files (.cc) need to be edited and modified, if I make PDF from crossploting attribute vs well data option, and what is the method. Thank you before.
Inline image 1

Regards,
Anne Queentina

Bert Bril

unread,
Aug 31, 2017, 8:11:07 AM8/31/17
to devel...@opendtect.org
Anne Queentina wrote:


> In additional, I want to know which part of source files (.cc) need to
> be edited and modified, if I make PDF from crossploting attribute vs
> well data option, and what is the method.

Two more, I hate to say poorly defined questions. I'll try to be general
so maybe I'm answering some of your questions.


By changing the implementation of Gaussian2DProbDenFunc::gtVal you have
basically removed the actual Gaussian 2D PDF's values. So where you
specify things for a Gaussian 2D PDF in the UI, you are actually
specifying things for your own type PDF.

That also means the behavior of only this type of PDF is affected. Thus,
the PDF created using Manage-Probability Density Functions 'generate'
tool button, option 'Create a Full Gaussian PDF' will no longer give
results for Gaussian, but as per your gtVal() function.

The same wizard also gives you the option to generate a sampled PDF from
a Gaussian specification. Check the first option 'Create an editable PDF
filled with Gaussian values' (screenshot). In that case, rather than
making a 'in-place' PDF, it will evaluate the Gaussian PDF at bin
locations. Where the 'in-place' Gaussian PDF is more correct as such,
the binned one can be manipulated. Again, the evaluation will use your code.


That is where the 'reach' of your changes stops.


The window you are showing is another way to generate a sampled PDF.
This is from data cross-plots. Your code changes will have no effect
whatsoever on this, as it is a simple bin-and-count operation,
generating a sampled PDF.

Sampled PDFs are pretty fundamental things that use N-dimensional
histograms. It is reasonably easy to imagine how to make cumulative
distributions out of this, and thus how to draw new values from the
distribution. This is implemented in Algo/probdenfunc.cc.

Lastly, to edit PDFs use the facilty in the same Manage-PDFs window,
it's the tool button just above the create button in the Manage window
(see screenshot).
cr_sampled_pdf.png
ed_sampled_pdf.png

Anne Queentina

unread,
Sep 13, 2017, 2:00:48 AM9/13/17
to Bert Bril, devel...@opendtect.org
Dear Sir,

Thank you advice making a PDF from data crossplot. As far I understood, The scripts that related to create PDF are dpsdensitycalc.cc, uiprobdenfunvarsel.cc, uicreatedpspdf.cc, probdenfunc.cc, and probdenfunctr.cc, and the main core of computing PDF are uicreatedpspdf.cc and dpsdensitycalc.cc.

Need your advice the script to be edited to change the calculation in dpsdensitycalc.cc just like gaussianprobdenfunc.cc.

The script of uicreatedpspdf.cc

DPSDensityCalcND::CalcAreaType areatype = DPSDensityCalcND::All;

if ( createfrmfld_ )

areatype =(DPSDensityCalcND::CalcAreaType) createfrmfld_->currentItem();

DPSDensityCalcND denscalc( dps_, axisparams, pdf.getData(), areatype );

if ( plotter_ )

denscalc.setGroup( plotter_->curGroup() );

uiTaskRunner taskrunner( this );

TaskRunner::execute( &taskrunner, denscalc );


The script of dpsdensitycalc.cc

float DPSDensityCalcND::getVal( int dcid, int drid ) const

{

if ( dcid >= 0 )

{

const float val = dps_.value( dcid, drid );

const UnitOfMeasure* mu = dps_.colDef( dcid ).unit_;

return mu ? mu->userValue(val) : val;

}

else if ( dcid == -1 )

{

const float val = dps_.z( drid );

return val*SI().zDomain().userFactor();

}

return dcid == (float) ( -3 ? dps_.coord(drid).x_ : dps_.coord(drid).y_ );

}


Regards,

Anne Queentina


--
You received this message because you are subscribed to the Google Groups "OpendTect Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@opendtect.org.
To post to this group, send email to devel...@opendtect.org.
Visit this group at https://groups.google.com/a/opendtect.org/group/developers/.
To view this discussion on the web visit https://groups.google.com/a/opendtect.org/d/msgid/developers/9c7010f7-77a1-17db-c7bc-0fd194cc35aa%40dgbes.com.

Bert Bril

unread,
Sep 14, 2017, 6:43:06 AM9/14/17
to devel...@opendtect.org
Anne:


> Thank you advice making a PDF from data crossplot. As far I understood,
> The scripts that related to create PDF
> are dpsdensitycalc.cc, uiprobdenfunvarsel.cc, uicreatedpspdf.cc, probdenfunc.cc,
> and probdenfunctr.cc, and the main core of computing PDF are
> uicreatedpspdf.cc and dpsdensitycalc.cc.
>
> Need your advice the script to be edited to change the calculation in
> dpsdensitycalc.cc just like gaussianprobdenfunc.cc.

No idea what you want.

Can you clearly state what you need, what you already tried, why you
want it, alternatives, etc.? All I see is code grabbed from the
OpendTect source tree.


Please take a look at:

http://www.catb.org/esr/faqs/smart-questions.html
Reply all
Reply to author
Forward
0 new messages