prob

package
v0.0.0-...-e5f6589 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func OptionLaplaceSmoothing

func OptionLaplaceSmoothing[V cmp.Ordered](freq *Prob[V])

Types

type Option

type Option[V cmp.Ordered] func(*Prob[V])

type Prob

type Prob[V cmp.Ordered] struct {
	// contains filtered or unexported fields
}

func Load

func Load[V cmp.Ordered](input *pb.Prob) *Prob[V]

nolint

func NewProb

func NewProb[V cmp.Ordered](opts ...Option[V]) *Prob[V]

func (*Prob[V]) Add

func (p *Prob[V]) Add(items []V)

func (*Prob[V]) Prob

func (p *Prob[V]) Prob(val V) float64

func (*Prob[V]) Proto

func (p *Prob[V]) Proto() *pb.Prob

nolint

Example
package main

import (
	"fmt"

	"github.com/xuender/aime/prob"
)

func main() {
	pro := prob.NewProb[int]()
	pro.Add([]int{1, 2, 3, 4})
	pro.Add([]int{5, 6, 7, 8})

	newPro := prob.Load[int](pro.Proto())

	fmt.Println(newPro.Total())

}
Output:

2

func (*Prob[V]) Total

func (p *Prob[V]) Total() float64

Jump to

Keyboard shortcuts

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