Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F11222131
test_InterpolatedCompositeBuilder.cc
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
test_InterpolatedCompositeBuilder.cc
View Options
#include
"UnitTest++.h"
#include
"test_utils.hh"
#include
"geners/CPP11_array.hh"
#include
"npstat/stat/buildInterpolatedCompositeDistroND.hh"
#include
"npstat/stat/DummyCompositeDistroBuilder.hh"
#include
"npstat/stat/buildInterpolatedDistro1DNP.hh"
#include
"npstat/stat/DummyDistro1DBuilder.hh"
using
namespace
npstat
;
using
namespace
std
;
#define PREDICTOR_DIM 2
namespace
{
TEST
(
symbetaInTheUnitBoxCenter
)
{
double
coords
[
PREDICTOR_DIM
];
for
(
unsigned
i
=
0
;
i
<
PREDICTOR_DIM
;
++
i
)
coords
[
i
]
=
0.5
;
const
double
smallBw
=
0.05
;
for
(
int
ipow
=-
1
;
ipow
<
10
;
++
ipow
)
{
const
double
effR
=
Private
::
symbetaEffRatioInsideUnitBox
(
ipow
,
smallBw
,
coords
,
PREDICTOR_DIM
);
const
double
bw
=
Private
::
symbetaBandwidthInsideUnitBox
(
ipow
,
effR
,
coords
,
PREDICTOR_DIM
);
CHECK_CLOSE
(
smallBw
,
bw
,
1.0e-8
);
if
(
ipow
==
0
)
CHECK_CLOSE
(
pow
(
2
*
smallBw
,
PREDICTOR_DIM
),
effR
,
1.0e-9
);
}
}
TEST
(
symbetaInsideUnitBox
)
{
double
coords
[
PREDICTOR_DIM
];
const
BoxND
<
double
>&
ubox
=
BoxND
<
double
>::
unitBox
(
PREDICTOR_DIM
);
for
(
unsigned
icycle
=
0
;
icycle
<
100
;
++
icycle
)
{
for
(
unsigned
i
=
0
;
i
<
PREDICTOR_DIM
;
++
i
)
coords
[
i
]
=
test_rng
();
const
double
initBw
=
0.1
+
0.9
*
test_rng
();
for
(
int
ipow
=-
1
;
ipow
<
10
;
++
ipow
)
{
const
double
effR
=
Private
::
symbetaEffRatioInsideUnitBox
(
ipow
,
initBw
,
coords
,
PREDICTOR_DIM
);
if
(
ipow
==
0
)
{
BoxND
<
double
>
box
;
for
(
unsigned
i
=
0
;
i
<
PREDICTOR_DIM
;
++
i
)
box
.
push_back
(
Interval
<
double
>
(
coords
[
i
]
-
initBw
,
coords
[
i
]
+
initBw
));
CHECK_CLOSE
(
box
.
overlapVolume
(
ubox
),
effR
,
1.0e-9
);
}
// We can have effR == 1.0 for ipow == 0
assert
(
effR
<
1.0
+
1.0e-12
);
if
(
effR
<
1.0
-
1.0e-7
)
{
const
double
bw
=
Private
::
symbetaBandwidthInsideUnitBox
(
ipow
,
effR
,
coords
,
PREDICTOR_DIM
);
CHECK_CLOSE
(
initBw
,
bw
,
1.0e-7
);
}
}
}
}
TEST
(
buildInterpolatedCompositeDistroNDGrid
)
{
const
unsigned
nAllDims
=
PREDICTOR_DIM
+
2
;
typedef
CPP11_array
<
float
,
nAllDims
>
Point
;
const
unsigned
npoints
=
100000
;
const
double
nEffWanted
=
10000
;
const
int
symbetaPower
=
4
;
const
bool
stretchKernels
=
true
;
const
bool
printMessages
=
false
;
std
::
vector
<
Point
>
data
;
data
.
reserve
(
npoints
);
Point
p0
;
for
(
unsigned
i
=
0
;
i
<
npoints
;
++
i
)
{
for
(
unsigned
idim
=
0
;
idim
<
nAllDims
;
++
idim
)
p0
[
idim
]
=
idim
+
(
2
+
idim
)
*
test_rng
();
data
.
push_back
(
p0
);
}
unsigned
dimPredictors
[
PREDICTOR_DIM
],
predBins
[
PREDICTOR_DIM
];
for
(
unsigned
i
=
0
;
i
<
PREDICTOR_DIM
;
++
i
)
{
dimPredictors
[
i
]
=
nAllDims
-
1
-
i
;
predBins
[
i
]
=
10
;
}
unsigned
dimResponse
[
2
]
=
{
0U
,
1U
};
DummyCompositeDistroBuilder
<
Point
>
dummyBuilder
;
buildInterpolatedCompositeDistroND
(
data
,
dimPredictors
,
PREDICTOR_DIM
,
0
,
predBins
,
symbetaPower
,
nEffWanted
,
stretchKernels
,
dimResponse
,
2
,
dummyBuilder
,
true
,
printMessages
);
DummyDistro1DBuilder
<
Point
>
dummyBuilder1D
;
buildInterpolatedDistro1DNP
(
data
,
dimPredictors
,
PREDICTOR_DIM
,
0
,
predBins
,
symbetaPower
,
nEffWanted
,
stretchKernels
,
dimResponse
[
1
],
dummyBuilder1D
,
false
,
printMessages
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Wed, May 14, 11:27 AM (16 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5077423
Default Alt Text
test_InterpolatedCompositeBuilder.cc (3 KB)
Attached To
rNPSTATSVN npstatsvn
Event Timeline
Log In to Comment