theorem

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2022 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package theorem is an Bayes' theorem implementation.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bayes

func Bayes(PriorPtoB, PriorPfromAtoB, PriorPNotFromAtoB float64) float64

Bayes returns the probability from the given probability based on Bayes' theorem.

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

	// 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL