Index: trunk/tests/test_randomTukeyDepth.cc =================================================================== --- trunk/tests/test_randomTukeyDepth.cc (revision 902) +++ trunk/tests/test_randomTukeyDepth.cc (revision 903) @@ -1,48 +1,85 @@ #include #include "UnitTest++.h" #include "test_utils.hh" #include "npstat/rng/MersenneTwister.hh" #include "npstat/stat/randomTukeyDepth.hh" using namespace npstat; namespace { - TEST(randomTukeyDepth_1d) + TEST(randomTukeyDepth1_1d) { MersenneTwister rng; const Matrix covmat(1, 1, 1); for (unsigned sampleSize=3; sampleSize<10; ++sampleSize) { std::vector > vec(sampleSize); Matrix sample(sampleSize, 1); for (unsigned i=0; i(x, i); sample[i][0] = x; } std::vector depth(sampleSize); randomTukeyDepth1(sample, rng, covmat, 1U, &depth[0], depth.size()); CHECK_EQUAL(0.0, *std::min_element(depth.begin(), depth.end())); CHECK_EQUAL(1.0, *std::max_element(depth.begin(), depth.end())); - + unsigned maxPossibleOrder = sampleSize/2U; if (sampleSize % 2U == 0U) --maxPossibleOrder; const double med = maxPossibleOrder; std::sort(vec.begin(), vec.end()); for (unsigned ipt=0, ipt2=sampleSize-1U; ipt covmat(1, 1, 1); + + for (unsigned sampleSize=3; sampleSize<10; ++sampleSize) + { + std::vector > vec(sampleSize); + Matrix sample(sampleSize, 1); + for (unsigned i=0; i(x, i); + sample[i][0] = x; + } + + std::vector depth(sampleSize); + randomTukeyDepth2(sample, sample, rng, covmat, 1U, + &depth[0], depth.size()); + CHECK_CLOSE(0.0, *std::min_element(depth.begin(), depth.end()), 1.0/sampleSize); + CHECK_CLOSE(1.0, *std::max_element(depth.begin(), depth.end()), 1.0/sampleSize); + + unsigned maxPossibleOrder = sampleSize/2U; + if (sampleSize % 2U == 0U) + --maxPossibleOrder; + const double med = maxPossibleOrder; + + std::sort(vec.begin(), vec.end()); + for (unsigned ipt=0, ipt2=sampleSize-1U; ipt