scores3D {BMAmevt} | R Documentation |
L^2
distance between two densities on the simplex (trivariate case).Computes the Kullback-Leibler divergence and the L^2
distance between the "true" density (true.dens
) and an estimated density (est.dens
).
scores3D(true.dens, est.dens, npoints, eps)
true.dens |
A |
est.dens |
The estimated density: of the same type as |
npoints |
Number of grid points used to construct the density matrices (see |
eps |
Minimum distance from a grid point to the simplex boundary (see |
The integration is made via rect.integrate
: The discretization grid corresponding to the two matrices must be constructed
with discretize(npoints, eps, equi=FALSE)
.
A list made of
check.true
: The result of the rectangular integration of
true.dens
. It should be equal to one. If not, re size the grid.
check.true
:
Idem, replacing true.dens
with est.dens
.
L2score
: The estimated L^2
distance.
KLscore
: The estimated Kullback-Leibler divergence between the two re-normalized densities, using check.true
and check.est
as normalizing constants (this ensures that the divergence is always positive).
dens1=dpairbeta.grid(par=c(0.8,2,5,8),npoints=150,eps=1e-3,
equi=FALSE)
dens2=dnestlog.grid(par=c(0.5,0.8,0.4,0.6),npoints=150,eps=1e-3, equi=FALSE)
scores3D(true.dens=dens1,
est.dens=dens2,
npoints=150, eps=1e-4)