Documentation
¶
Overview ¶
package prob defines various types and functions for manipulating discrete probability distributions
Index ¶
- type Comparator
- type Dist
- func FlatMap[T any, U any](dist Dist[T], mapper func(T) Dist[U]) (Dist[U], error)
- func FromConst[T any](v T) (Dist[T], error)
- func FromEntries[T any](m []EntryT[T]) (Dist[T], error)
- func FromMap[T comparable](m MapT[T]) (Dist[T], error)
- func Map[T any, U any](dist Dist[T], mapper func(T) U) (Dist[U], error)
- func Reduce[T any, U any](dists []Dist[T], collector func(U, T) U, initialValue U) (Dist[U], error)
- func (d Dist[T]) Distribution() Dist[T]
- func (d Dist[T]) Format(w fmt.State, v rune)
- func (d Dist[T]) Iter() iter.Seq2[T, *big.Rat]
- func (d Dist[T]) Keys() []Key
- func (d Dist[T]) Lookup(k Key) (EntryT[T], bool)
- func (d Dist[T]) Median(cmp func(T, T) int) T
- func (d Dist[T]) Percentile(p float64, cmp func(T, T) int) T
- func (d Dist[T]) StringKey() string
- type EntryT
- type Key
- type MapT
- type StringKeyer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comparator ¶
type Dist ¶
type Dist[T any] struct { // contains filtered or unexported fields }
a discrete probability distribution
func FlatMap ¶
FlatMap maps each outcome of a probability distribution of outcome T to a new probability distribution with outcome U and flattens the results into a single distribution of outcome U
func Reduce ¶
func Reduce[T any, U any]( dists []Dist[T], collector func(U, T) U, initialValue U, ) (Dist[U], error)
reduces probability distributions of multiple independent events into an aggregate probability distribution
func (Dist[T]) Distribution ¶
func (Dist[T]) Percentile ¶
type MapT ¶
type MapT[T comparable] = map[T]*big.Rat
type StringKeyer ¶
type StringKeyer interface {
StringKey() string
}
Click to show internal directories.
Click to hide internal directories.