close Warning: Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.

Opened 21 years ago

Closed 19 years ago

Last modified 18 years ago

#52 closed defect (fixed)

Density Functions Correction

Reported by: jcaballero Owned by: Jorge
Priority: normal Milestone:
Component: Math Version: head
Severity: normal Keywords:
Cc:

Description

Hello all:

We're Antonio Cerdán, Andrés Martínez and Jorge Caballero from Bayes.

We have detected anomalies in density functions integrated in TOL; we have
created a new function: Eulerian gamma Integral:

1) Uniform Density Function
2) gamma Eulerian function
3) Gamma Density Funtion
4) Exponential Density Function

/

/
Real DensUnif( Real x, Real a, Real b)
/
{

Real salida = If(And(LE(a,x),GE(b,x)),1/(b-a),0);
salida

};
/
PutDescription("Density Uniform(a,b)",DensUnif);
/

/
Real gamma( Real alpha)
/
{

Real UserFunc00(Matrix X)
{

Real theta = MatDat(X,1,1);
theta(alpha-1)*Exp(-theta)

};
If(IsInteger(alpha),Factorial(alpha-1),
{

Set vegas = MonteCarloVegas(UserFunc00,1,Col(0),Col(300*alpha),1000,

10000);

WriteLn("gamma("<<alpha<<")="<<vegas[1]);
vegas[1]

})

};
/
PutDescription("Eulerian improper gamma integral ",gamma);
/

/
Real DensGam(Real x, Real alpha, Real beta)
/
{

Real func = If(GE(x,0),x(alpha-1)*Exp(-beta*x),0);
Real cte = gamma(x);
Real output = cte*func;
output

};
/
PutDescription("Gamma Density constructed from Eulerian gamma",
DensGam);
/


Real DensExpon(Real x, Real lambda)

{

Real output = If(GE(x,0),lambda*Exp(-lambda*x),0);
output

};
/
PutDescription("Exponential Density Function with parameter lambda",
DensExpon);
/

/

Follows the explication about the old functions did not work:

1) Uniform:

DensUniform(Real x, Real a, Real b);

Example:

Real a = DensUniform(1,0,2);
Return a = 1, when the true value is a = 0.5

Because of the pdf is:

f(x) = 1/(b-a), si x belong to (a,b) or
f(x) = 0 , otherwise

With the new pdf will be:

Real a = DensUnif(1,0,2);
Obtaining a = 0.5

2) Gamma Density Function:

DensGamma(Real x,Real p);

The Gamma Density Function needs 3 parameters:

DensGamma(Real x,Real p, Real q);
We have verify that the value for q is 1 by defect in the old pdf, where q is
the exponential parameter.

With the new pdf DensGamma(Real x,Real p);
Real a = DensGam(3,1,4);
The true value is: a = 0.000012

3) Exponential pdf:

DensExp(Real x);

The Exponential Density Function needs 2 parameters, present pdf don' t work.

With the new pdf:

Real a = DensExpon(3,1);
The true value is: a = 0.049787;

Best regards.

Bayes Team for TdE

Change History (3)

comment:1 Changed 21 years ago by Jorge

Status: newassigned

comment:2 Changed 19 years ago by Jorge

Resolution: fixed
Status: assignedclosed

Fixed. Just a few comments:

The Gamma density use parameter scale instead of rate = 1/scale. See the
description of the function.

Exponential use the parameter scale instead of rate = 1/scale. Idem

comment:3 Changed 18 years ago by Víctor de Buen Remiro

bug_file_loc: http://cvs.tol-project.org/viewcvs.cgi/tol_tests/tol/Bugzilla/bug_000052
Note: See TracTickets for help on using tickets.