74 double expected_1 = 1;
79 double expected_2 = 0.5;
84 double expected_3 = 0.333333;
85 double var_3 = 0.111111;
86 double std_3 = 0.333333;
89 double lambda_5 = -2.3;
91 const float threshold = 1e-3f;
93 std::cout <<
"Test for lambda = 1 \n";
95 std::abs(expected_1 - probability::geometric_dist::exponential_expected(
96 lambda_1)) < threshold);
97 assert(std::abs(var_1 - probability::geometric_dist::exponential_var(
98 lambda_1)) < threshold);
99 assert(std::abs(std_1 - probability::geometric_dist::exponential_std(
100 lambda_1)) < threshold);
101 std::cout <<
"ALL TEST PASSED\n\n";
103 std::cout <<
"Test for lambda = 2 \n";
105 std::abs(expected_2 - probability::geometric_dist::exponential_expected(
106 lambda_2)) < threshold);
107 assert(std::abs(var_2 - probability::geometric_dist::exponential_var(
108 lambda_2)) < threshold);
109 assert(std::abs(std_2 - probability::geometric_dist::exponential_std(
110 lambda_2)) < threshold);
111 std::cout <<
"ALL TEST PASSED\n\n";
113 std::cout <<
"Test for lambda = 3 \n";
115 std::abs(expected_3 - probability::geometric_dist::exponential_expected(
116 lambda_3)) < threshold);
117 assert(std::abs(var_3 - probability::geometric_dist::exponential_var(
118 lambda_3)) < threshold);
119 assert(std::abs(std_3 - probability::geometric_dist::exponential_std(
120 lambda_3)) < threshold);
121 std::cout <<
"ALL TEST PASSED\n\n";
123 std::cout <<
"Test for lambda = 0 \n";
125 probability::geometric_dist::exponential_expected(lambda_4);
126 probability::geometric_dist::exponential_var(lambda_4);
127 probability::geometric_dist::exponential_std(lambda_4);
128 }
catch (std::invalid_argument& err) {
129 assert(std::string(err.what()) ==
"lambda must be greater than 0");
131 std::cout <<
"ALL TEST PASSED\n\n";
133 std::cout <<
"Test for lambda = -2.3 \n";
135 probability::geometric_dist::exponential_expected(lambda_5);
136 probability::geometric_dist::exponential_var(lambda_5);
137 probability::geometric_dist::exponential_std(lambda_5);
138 }
catch (std::invalid_argument& err) {
139 assert(std::string(err.what()) ==
"lambda must be greater than 0");
141 std::cout <<
"ALL TEST PASSED\n\n";