bayes

package
v0.0.0-...-713b49f Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2015 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func PHole

func PHole(hd *HandDist, scards []string) float64

PHole returns the probability of having a given class of hole cards given that scards have already been seen.

Here are two example calculations:

          Me   Opp  Board  P(AA)
Pre-deal  ??   ??   ???    (4 choose 2) / (52 choose 2) ~= 0.0045
Pre-flop  AKs  ??   ???    (3 choose 2) / (50 choose 2) ~= 0.0024

Types

type HandDist

type HandDist struct {
	Dist string
}

A hand distribution is a category of hands. Currently the only categories supported are those of the forms AA, AKo, and AKs.

func (*HandDist) Ints

func (this *HandDist) Ints() [][]int32

The same as Strs, only return the hands represented by int32.

func (*HandDist) Strs

func (this *HandDist) Strs() [][]string

Expand the HandDist into a slice of all possible hands.

type Lottery

type Lottery struct {
	// contains filtered or unexported fields
}

func NewLottery

func NewLottery(dist map[string]float64) *Lottery

Convert a discrete distribution (array-map {item prob}) into a lottery. The probabilities should add up to 1

Example
lotto := NewLottery(map[string]float64{"a": 0.4, "b": 0.1, "c": 0.5, "d": 0})
fmt.Println(lotto)
for i := 0; i < 100; i++ {
	lotto.Play()
}
Output:

[ a:0.40 c:0.90 b:1.00 ]

func (*Lottery) Play

func (this *Lottery) Play() string

Draw a winner from a Lottery. If at least one value in the lottery is not >= 1, then the greatest value is effectively rounded up to 1.0"

func (*Lottery) String

func (this *Lottery) String() string

type PTable

type PTable struct {
	*Table
}

func (*PTable) String

func (this *PTable) String() string

type Table

type Table struct {
	Data       []float64
	Rows, Cols []string // row and column labels
}

func ReadTable

func ReadTable(file string) (*Table, error)

func (*Table) At

func (this *Table) At(i, j int) float64

func (*Table) P

func (this *Table) P() *PTable

P returns a table showing the probabilities of the row field given the column field.

func (*Table) PCR

func (this *Table) PCR() *PTable

PCR returns a table showing the probabilities of the column field given the row field.

func (*Table) Set

func (this *Table) Set(i, j int, v float64)

func (*Table) String

func (this *Table) String() string

func (*Table) Sums

func (this *Table) Sums() ([]float64, []float64, float64)

Sums returns the the row and column sums as slices and the grand total.

Jump to

Keyboard shortcuts

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