Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bayes ¶
Bayes is a trivial implemention of Bayes' rule. We assume probB is already the sum of all the posteriors for B (its prior) for all possible values of A. NEEDS TESTS
func MassGeometric ¶
MassGeometric returns a probability mass function (PMF) which computes the probability that a given event will occur for the first time after (x-1) nonoccurrences - so the event occurs on the xth opportunity. p is the probabiliity of the event occurring, 1-p is its complement, and the full function is given by (1-p)^(x-1) * p. NEEDS TESTS
Types ¶
type DiscretizationConfig ¶
type DiscretizationConfig struct { Intervals int Method DiscretizationMethod IncludeUpperBound bool // Unused for now }
DiscretizationConfig controls the behavior of discretization of a continuous range of values. Intervals is the number of intervals, Method determines how the range is subdivided, and IncludeUpperBound toggles whether each interval includes its upper bound (default of false means that only the last interval includes its upper bound, all others exclude it).
type DiscretizationMethod ¶
type DiscretizationMethod int
const ( IntervalEqualSize DiscretizationMethod = iota // Every interval is the same size IntervalEqualDistribution DiscretizationMethod = iota // Every interval contains the same number of known values DefaultIntervalCount = 10 )
type Interval ¶
type Interval struct { Lower float64 Upper float64 Size float64 IncludesLower bool IncludesUpper bool }
func Discretize ¶
func Discretize(vals []float64, cfg DiscretizationConfig) []Interval
Discretize converts a continuous (real-valued) range into a set of discrete intervals. vals is the set of known values within the range. Pass an empty config object to get the default behavior of 10 intervals, each interval is of equal size, every interval but the last includes its lower bound and excludes its upper bound. The last interval includes both bounds by default.
type Intervals ¶
type Intervals []Interval
func (Intervals) IntervalForValue ¶
IntervalForValue returns the index 0..(len(is) - 1) of the Interval containing the passed value
type ProbabilityMassFunction ¶
func MassDiscrete ¶
func MassDiscrete(values []int) ProbabilityMassFunction
MassDiscrete returns a probability mass function (PMF) over the range of values which can be assigned to a given random variable. The variable has a discrete range, and the values must represent the full sample space.