Co-Simulation/Sumo/sumo-1.7.0/unittest/src/utils/common/RandHelperTest.cpp
/* Test whether the 'randNorm' distribution is more or less gaussian.*/
Test whether the 'randNorm' distribution is more or less gaussian.
Test whether the ' randNorm ' distribution is more or less gaussian .
TEST(RandHelper, test_norm) {
    int count[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    for (int i = 0; i < 1000; i++) {
        const double rand = RandHelper::randNorm(double(5), double(2));
        count[MIN2(MAX2((int)rand, 0), 9)]++;
    }
    EXPECT_LE(0, count[0]);
    EXPECT_LT(count[0], 100);
    EXPECT_LE(0, count[1]);
    EXPECT_LT(count[1], 100);
    EXPECT_LE(50, count[2]);
    EXPECT_LT(count[2], 150);
    EXPECT_LE(100, count[3]);
    EXPECT_LT(count[3], 200);
    EXPECT_LE(100, count[4]);
    EXPECT_LT(count[4], 250);
    EXPECT_LE(100, count[5]);
    EXPECT_LT(count[5], 250);
    EXPECT_LE(100, count[6]);
    EXPECT_LT(count[6], 200);
    EXPECT_LE(0, count[7]);
    EXPECT_LT(count[7], 100);
    EXPECT_LE(0, count[8]);
    EXPECT_LT(count[8], 100);
    EXPECT_LE(0, count[9]);
    EXPECT_LT(count[9], 100);
}
TEST ( RandHelper , test_norm ) { int count [ ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; for ( int i = 0 ; i < 1000 ; i ++ ) { const double rand = RandHelper :: randNorm ( double ( 5 ) , double ( 2 ) ) ; count [ MIN2 ( MAX2 ( ( int ) rand , 0 ) , 9 ) ] ++ ; } EXPECT_LE ( 0 , count [ 0 ] ) ; EXPECT_LT ( count [ 0 ] , 100 ) ; EXPECT_LE ( 0 , count [ 1 ] ) ; EXPECT_LT ( count [ 1 ] , 100 ) ; EXPECT_LE ( 50 , count [ 2 ] ) ; EXPECT_LT ( count [ 2 ] , 150 ) ; EXPECT_LE ( 100 , count [ 3 ] ) ; EXPECT_LT ( count [ 3 ] , 200 ) ; EXPECT_LE ( 100 , count [ 4 ] ) ; EXPECT_LT ( count [ 4 ] , 250 ) ; EXPECT_LE ( 100 , count [ 5 ] ) ; EXPECT_LT ( count [ 5 ] , 250 ) ; EXPECT_LE ( 100 , count [ 6 ] ) ; EXPECT_LT ( count [ 6 ] , 200 ) ; EXPECT_LE ( 0 , count [ 7 ] ) ; EXPECT_LT ( count [ 7 ] , 100 ) ; EXPECT_LE ( 0 , count [ 8 ] ) ; EXPECT_LT ( count [ 8 ] , 100 ) ; EXPECT_LE ( 0 , count [ 9 ] ) ; EXPECT_LT ( count [ 9 ] , 100 ) ; }
Test whether the 'randNorm' distribution is more or less gaussian.
Test whether the ' randNorm ' distribution is more or less gaussian .