addition_rule.cpp File Reference

Addition rule of probabilities. More...

`#include <iostream>`
Include dependency graph for addition_rule.cpp:

## Functions

double | addition_rule_independent (double A, double B)
double | addition_rule_dependent (double A, double B, double B_given_A)
int | main ()

## Detailed Description

Addition rule of probabilities.

## Function Documentation

## addition_rule_dependent()

double addition_rule_dependent | ( | double | A,
|  | double | B,
|  | double | B_given_A
| ) |  |

Calculates the probability of the events A or B for dependent events note that if value of B_given_A is unknown, use chainrule to find it \parama [in] A probability of event A \parama [in] B probability of event B \parama [in] B_given_A probability of event B condition A

Returns
  probability of A and B

{
return (A + B) - (A * B_given_A);
}

## addition_rule_independent()

double addition_rule_independent | ( | double | A,
|  | double | B
| ) |  |

calculates the probability of the independent events A or B for independent events \parama [in] A probability of event A \parama [in] B probability of event B

Returns
  probability of A and B

{
return (A + B) - (A * B);
}

## main()

int main | ( | void |  | ) |

Main function

{
double A = 0.5;
double B = 0.25;
double B_given_A = 0.05;
std::cout << "independent P(A or B) = " << addition_rule_independent(A, B)
<< std::endl;
std::cout << "dependent P(A or B) = "
<< addition_rule_dependent(A, B, B_given_A) << std::endl;
return 0;
}
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
std::cout
std::endl
T endl(T... args)
Here is the call graph for this function: