Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F11221276
test_KDE1DKernel.cc
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
test_KDE1DKernel.cc
View Options
#include
"UnitTest++.h"
#include
"test_utils.hh"
#include
<vector>
#include
<algorithm>
#include
"npstat/stat/AbsKDE1DKernel.hh"
#include
"npstat/stat/KDE1DHOSymbetaKernel.hh"
#include
"npstat/stat/Distributions1D.hh"
using
namespace
npstat
;
namespace
{
TEST
(
KDE1DKernel_1
)
{
const
unsigned
npseudo
=
1000
;
const
unsigned
npoints
=
100
;
const
double
h
=
0.3
;
Uniform1D
uni
(
-
0.3
,
1.0
);
KDE1DDensityKernel
K
(
uni
);
std
::
vector
<
float
>
data
(
npoints
);
for
(
unsigned
ips
=
0
;
ips
<
npseudo
;
++
ips
)
{
for
(
unsigned
i
=
0
;
i
<
npoints
;
++
i
)
data
[
i
]
=
test_rng
()
-
0.5
;
std
::
sort
(
data
.
begin
(),
data
.
end
());
for
(
unsigned
i
=
0
;
i
<
npoints
;
++
i
)
{
const
double
x
=
2.0
*
(
test_rng
()
-
0.5
);
const
double
d1
=
K
.
kde
(
x
,
h
,
&
data
[
0
],
npoints
,
true
);
const
double
d2
=
K
.
kde
(
x
,
h
,
&
data
[
0
],
npoints
,
false
);
CHECK
(
d1
==
d2
);
const
double
d3
=
K
.
reverseKde
(
x
,
h
,
&
data
[
0
],
npoints
,
true
);
const
double
d4
=
K
.
reverseKde
(
x
,
h
,
&
data
[
0
],
npoints
,
false
);
CHECK
(
d3
==
d4
);
}
}
}
TEST
(
KDE1DHOGaussKernel_moments
)
{
const
double
eps
=
1.0e-12
;
const
unsigned
nIntegPoints
=
1024
;
KDE1DHOSymbetaKernel
kernel
(
-
1
,
4
);
CHECK_CLOSE
(
1.0
,
kernel
.
momentIntegral
(
0
,
nIntegPoints
),
eps
);
for
(
unsigned
i
=
1
;
i
<
6
;
++
i
)
CHECK_CLOSE
(
0.0
,
kernel
.
momentIntegral
(
i
,
nIntegPoints
),
eps
);
}
TEST
(
KDE1DHOSymbetaKernel_moments
)
{
const
double
eps
=
1.0e-12
;
const
unsigned
nIntegPoints
=
1024
;
for
(
int
power
=
0
;
power
<
11
;
++
power
)
{
KDE1DHOSymbetaKernel
kernel
(
power
,
6
);
CHECK_CLOSE
(
1.0
,
kernel
.
momentIntegral
(
0
,
nIntegPoints
),
eps
);
for
(
unsigned
i
=
1
;
i
<
8
;
++
i
)
CHECK_CLOSE
(
0.0
,
kernel
.
momentIntegral
(
i
,
nIntegPoints
),
eps
);
}
}
TEST
(
KDE1DDensityKernel_copy
)
{
Gauss1D
g
(
0.0
,
1.0
);
KDE1DDensityKernel
k1
(
g
);
KDE1DDensityKernel
k2
(
k1
);
CHECK
(
k1
(
0.5
)
==
k2
(
0.5
));
}
TEST
(
KDE1DHOSymbetaKernel_copy
)
{
KDE1DHOSymbetaKernel
k1
(
4
,
6
);
KDE1DHOSymbetaKernel
k2
(
k1
);
CHECK
(
k1
(
0.5
)
==
k2
(
0.5
));
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Wed, May 14, 10:10 AM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5061384
Default Alt Text
test_KDE1DKernel.cc (2 KB)
Attached To
rNPSTATSVN npstatsvn
Event Timeline
Log In to Comment