Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F19243754
test_amiseOptimalBandwidth.cc
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
test_amiseOptimalBandwidth.cc
View Options
#include
"UnitTest++.h"
#include
"npstat/stat/amiseOptimalBandwidth.hh"
#include
"npstat/stat/Distributions1D.hh"
#include
"npstat/nm/ArrayND.hh"
using
namespace
npstat
;
using
namespace
std
;
namespace
{
class
GaussFunctor
{
public
:
GaussFunctor
(
double
sigma
,
double
nsigmas
,
unsigned
npoints
)
:
g_
(
0.0
,
sigma
),
min_
(
-
sigma
*
nsigmas
),
h_
(
fabs
(
2
*
min_
/
npoints
))
{}
inline
double
step
()
const
{
return
h_
;}
double
operator
()(
const
unsigned
*
loc
,
unsigned
n
)
const
{
return
g_
.
density
(
min_
+
(
*
loc
+
0.5
)
*
h_
);
}
private
:
GaussFunctor
();
Gauss1D
g_
;
double
min_
;
double
h_
;
};
// Reproduce the "rule of thumb"
TEST
(
amiseOptimalBandwidth
)
{
const
double
sigma
=
2.5
;
const
unsigned
nbins
=
1000
;
GaussFunctor
gf
(
sigma
,
6
,
nbins
);
ArrayND
<
double
>
arr
(
makeShape
(
nbins
));
arr
.
functorFill
(
gf
);
const
double
bw
=
amiseOptimalBwGauss
(
0
,
1
,
const_cast
<
double
*>
(
arr
.
data
()),
nbins
,
gf
.
step
());
CHECK_CLOSE
(
1.0592238410488
*
sigma
,
bw
,
1.e-4
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Tue, Sep 30, 4:35 AM (1 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6549645
Default Alt Text
test_amiseOptimalBandwidth.cc (1 KB)
Attached To
Mode
rNPSTATSVN npstatsvn
Attached
Detach File
Event Timeline
Log In to Comment