Documentation ¶
Overview ¶
Package theorem is an Bayes' theorem implementation.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bayes ¶
Bayes returns the probability from the given probability based on Bayes' theorem. In other words, it returns the probability of event B occurring when event A occurred.
- priorPtoB is the prior probability occurrence of event B.
- priorPfromAtoB is the prior probability occurrence of event B when previous event A occurred.
- priorPNotFromAtoB is the prior probability that did not occur event B when previous event A occurred.
Example ¶
package main import ( "fmt" "github.com/KEINOS/go-bayes/pkg/theorem" ) func main() { // Validation of figures // Bayes' theorem x := 0.3 * 0.4 y := x + (1.-0.3)*0.5 expect := x / y //nolint: ifshort // not using short syntax for readability // Prior probability to be B. PriorProbToB := 0.3 // Prior probability to be B if the previous was A. PriorProbFromAtoB := 0.4 // Prior probability not to be B if the previous was A. PriorProbNotFromAtoB := 0.5 actual := theorem.Bayes(PriorProbToB, PriorProbFromAtoB, PriorProbNotFromAtoB) if expect == actual { fmt.Println("OK") } }
Output: OK
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.