TheAlgorithms/C++
1.0.0
All the algorithms implemented in C++
Loading...
Searching...
No Matches
addition_rule.cpp
Go to the documentation of this file.
1
5
#include <iostream>
6
14
double
addition_rule_independent
(
double
A,
double
B) {
15
return
(A + B) - (A * B);
16
}
17
25
double
addition_rule_dependent
(
double
A,
double
B,
double
B_given_A) {
26
return
(A + B) - (A * B_given_A);
27
}
28
30
int
main
() {
31
double
A = 0.5;
32
double
B = 0.25;
33
double
B_given_A = 0.05;
34
35
std::cout <<
"independent P(A or B) = "
<<
addition_rule_independent
(A, B)
36
<< std::endl;
37
38
std::cout <<
"dependent P(A or B) = "
39
<<
addition_rule_dependent
(A, B, B_given_A) << std::endl;
40
41
return
0;
42
}
addition_rule_independent
double addition_rule_independent(double A, double B)
Definition
addition_rule.cpp:14
addition_rule_dependent
double addition_rule_dependent(double A, double B, double B_given_A)
Definition
addition_rule.cpp:25
main
int main()
Definition
addition_rule.cpp:30
probability
addition_rule.cpp
Generated by
1.12.0