A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d9/da2/exponential__dist_8cpp.html below:

TheAlgorithms/C++: probability/exponential_dist.cpp File Reference

Self-test implementations.

72 {

73 double lambda_1 = 1;

74 double expected_1 = 1;

75 double var_1 = 1;

76 double std_1 = 1;

77

78 double lambda_2 = 2;

79 double expected_2 = 0.5;

80 double var_2 = 0.25;

81 double std_2 = 0.5;

82

83 double lambda_3 = 3;

84 double expected_3 = 0.333333;

85 double var_3 = 0.111111;

86 double std_3 = 0.333333;

87

88 double lambda_4 = 0;

89 double lambda_5 = -2.3;

90

91 const float threshold = 1e-3f;

92

93 std::cout << "Test for lambda = 1 \n";

94 assert(

96 lambda_1)) < threshold);

98 lambda_1)) < threshold);

100 lambda_1)) < threshold);

101 std::cout << "ALL TEST PASSED\n\n";

102

103 std::cout << "Test for lambda = 2 \n";

104 assert(

106 lambda_2)) < threshold);

108 lambda_2)) < threshold);

110 lambda_2)) < threshold);

111 std::cout << "ALL TEST PASSED\n\n";

112

113 std::cout << "Test for lambda = 3 \n";

114 assert(

116 lambda_3)) < threshold);

118 lambda_3)) < threshold);

120 lambda_3)) < threshold);

121 std::cout << "ALL TEST PASSED\n\n";

122

123 std::cout << "Test for lambda = 0 \n";

124 try {

128 } catch (std::invalid_argument& err) {

129 assert(std::string(err.what()) == "lambda must be greater than 0");

130 }

131 std::cout << "ALL TEST PASSED\n\n";

132

133 std::cout << "Test for lambda = -2.3 \n";

134 try {

138 } catch (std::invalid_argument& err) {

139 assert(std::string(err.what()) == "lambda must be greater than 0");

140 }

141 std::cout << "ALL TEST PASSED\n\n";

142}

double exponential_expected(double lambda)

the expected value of the exponential distribution

double exponential_std(double lambda)

the standard deviation of the exponential distribution

double exponential_var(double lambda)

the variance of the exponential distribution


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4