#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);
})
};
/
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
Status: | new → assigned |
---|
comment:2 Changed 19 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:3 Changed 18 years ago by
bug_file_loc: | → http://cvs.tol-project.org/viewcvs.cgi/tol_tests/tol/Bugzilla/bug_000052 |
---|
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