generic

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: GPL-3.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaumWelchAlgorithm

func BaumWelchAlgorithm(obj baumWelchCore, meta ConstVector, nRecords, nData, nMapped, nStates, nEdists int, epsilon float64, maxSteps int, p ThreadPool, args ...interface{}) error

func EmAlgorithm

func EmAlgorithm(obj emCore, meta ConstVector, nData, nComponents int, epsilon float64, maxSteps int, p ThreadPool, args ...interface{}) error

Types

type BasicHmm

type BasicHmm interface {
	BasicDistribution
	String() string
}

type BasicMixture

type BasicMixture interface {
	BasicDistribution
	String() string
}

type BaumWelchHook

type BaumWelchHook struct {
	Value func(hmm BasicHmm, i int, likelihood, epsilon float64)
}

func DefaultBaumWelchHook

func DefaultBaumWelchHook(writer io.Writer) BaumWelchHook

func PlainBaumWelchHook

func PlainBaumWelchHook(writer io.Writer) BaumWelchHook

type BaumWelchOptimizeEmissions

type BaumWelchOptimizeEmissions struct {
	Value bool
}

type BaumWelchOptimizeTransitions

type BaumWelchOptimizeTransitions struct {
	Value bool
}

type BaumWelchTmp

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

type ChmmTransitionMatrix

type ChmmTransitionMatrix struct {
	Matrix
	// contains filtered or unexported fields
}

func NewChmmTransitionMatrix

func NewChmmTransitionMatrix(tr Matrix, constraints []EqualityConstraint, isLog bool) (ChmmTransitionMatrix, error)

func (ChmmTransitionMatrix) CloneTransitionMatrix

func (obj ChmmTransitionMatrix) CloneTransitionMatrix() TransitionMatrix

func (ChmmTransitionMatrix) EvalConstraints

func (obj ChmmTransitionMatrix) EvalConstraints(lambda ConstVector, x MagicVector) error

func (ChmmTransitionMatrix) GetConstraints

func (obj ChmmTransitionMatrix) GetConstraints() []EqualityConstraint

func (ChmmTransitionMatrix) GetMatrix

func (obj ChmmTransitionMatrix) GetMatrix() Matrix

func (ChmmTransitionMatrix) Normalize

func (obj ChmmTransitionMatrix) Normalize() error

type EmHook

type EmHook struct {
	Value func(mixture BasicMixture, i int, likelihood, epsilon float64)
}

func DefaultEmHook

func DefaultEmHook(writer io.Writer) EmHook

func PlainEmHook

func PlainEmHook(writer io.Writer) EmHook

type EmOptimizeEmissions

type EmOptimizeEmissions struct {
	Value bool
}

type EmOptimizeWeights

type EmOptimizeWeights struct {
	Value bool
}

type EmTmp

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

type EqualityConstraint

type EqualityConstraint [][2]int

func NewEqualityConstraint

func NewEqualityConstraint(x []int) (EqualityConstraint, error)

type HhmmTransitionMatrix

type HhmmTransitionMatrix struct {
	Matrix
	Tree HmmNode
}

func NewHhmmTransitionMatrix

func NewHhmmTransitionMatrix(tr Matrix, tree HmmNode, isLog bool) (HhmmTransitionMatrix, error)

func (HhmmTransitionMatrix) CloneTransitionMatrix

func (obj HhmmTransitionMatrix) CloneTransitionMatrix() TransitionMatrix

func (HhmmTransitionMatrix) GetMatrix

func (obj HhmmTransitionMatrix) GetMatrix() Matrix

func (HhmmTransitionMatrix) Normalize

func (obj HhmmTransitionMatrix) Normalize() error

type Hmm

type Hmm struct {
	Pi ProbabilityVector // initial probability vector
	Tr TransitionMatrix  // transition matrix
	Tf TransitionMatrix  // transition matrix for last transition
	// state equivalence classes define which states share the same
	// emission distribution
	StateMap []int
	// number of states
	M int
	// number of emission distributions
	N int
	// contains filtered or unexported fields
}

func NewHmm

func NewHmm(pi ProbabilityVector, tr TransitionMatrix, stateMap []int) (*Hmm, error)

func (*Hmm) BaumWelchStep

func (obj *Hmm) BaumWelchStep(hmm1, hmm2 *Hmm, data HmmDataSet, meta ConstVector, tmp []BaumWelchTmp, p ThreadPool) (float64, error)

func (*Hmm) Clone

func (obj *Hmm) Clone() *Hmm

func (*Hmm) ExportConfig

func (obj *Hmm) ExportConfig() ConfigDistribution

func (*Hmm) ForwardBackward

func (obj *Hmm) ForwardBackward(data HmmDataRecord) (Matrix, Matrix, error)

func (*Hmm) GetParameters

func (obj *Hmm) GetParameters() Vector

func (*Hmm) ImportConfig

func (obj *Hmm) ImportConfig(config ConfigDistribution, t ScalarType) error

func (*Hmm) LogPdf

func (obj *Hmm) LogPdf(r Scalar, data HmmDataRecord) error

func (*Hmm) NEDists

func (obj *Hmm) NEDists() int

func (*Hmm) NStates

func (obj *Hmm) NStates() int

func (*Hmm) Posterior

func (obj *Hmm) Posterior(r Scalar, data HmmDataRecord, states [][]int) error

Compute the posterior: P(Y_1 in y_1, Y_2 in y_2, ..., Y_n in y_n | X_1, dots, X_n)

func (*Hmm) PosteriorMarginals

func (obj *Hmm) PosteriorMarginals(data HmmDataRecord) ([]Vector, error)

func (*Hmm) ScalarType

func (obj *Hmm) ScalarType() ScalarType

func (*Hmm) SetFinalStates

func (obj *Hmm) SetFinalStates(states []int) error

func (*Hmm) SetParameters

func (obj *Hmm) SetParameters(parameters Vector) error

func (*Hmm) SetStartStates

func (obj *Hmm) SetStartStates(states []int) error

func (*Hmm) String

func (obj *Hmm) String() string

func (*Hmm) Viterbi

func (obj *Hmm) Viterbi(data HmmDataRecord) ([]int, error)

type HmmDataRecord

type HmmDataRecord interface {
	// map index of the kth observation
	MapIndex(k int) int
	// get number of observations in this record
	GetN() int
	// evaluate component c at position k
	LogPdf(r Scalar, c, k int) error
}

type HmmDataSet

type HmmDataSet interface {
	GetRecord(i int) HmmDataRecord
	// number of mapped observations
	GetNMapped() int
	// number of records in the data set
	GetNRecords() int
	// total number of observations
	GetN() int
}

type HmmNode

type HmmNode struct {
	Children []HmmNode
	States   [2]int
}

tree for describing the structure of the hierarchical hmm

func NewHmmLeaf

func NewHmmLeaf(from, to int) HmmNode

func NewHmmNode

func NewHmmNode(children ...HmmNode) HmmNode

func (HmmNode) Check

func (node HmmNode) Check(n int) bool

func (HmmNode) ExportConfig

func (node HmmNode) ExportConfig() interface{}

func (*HmmNode) ImportConfig

func (node *HmmNode) ImportConfig(v interface{}) bool

func (HmmNode) StdInit

func (node HmmNode) StdInit(tr Matrix, v []float64) error

type HmmProbabilityVector

type HmmProbabilityVector struct {
	Vector
	// contains filtered or unexported fields
}

func NewHmmProbabilityVector

func NewHmmProbabilityVector(v Vector, isLog bool) (HmmProbabilityVector, error)

func (HmmProbabilityVector) CloneProbabilityVector

func (obj HmmProbabilityVector) CloneProbabilityVector() ProbabilityVector

func (HmmProbabilityVector) GetVector

func (obj HmmProbabilityVector) GetVector() Vector

func (HmmProbabilityVector) Normalize

func (obj HmmProbabilityVector) Normalize() error

type HmmTransitionMatrix

type HmmTransitionMatrix struct {
	Matrix
	// contains filtered or unexported fields
}

func NewHmmTransitionMatrix

func NewHmmTransitionMatrix(tr_ Matrix, isLog bool) (HmmTransitionMatrix, error)

func (HmmTransitionMatrix) CloneTransitionMatrix

func (obj HmmTransitionMatrix) CloneTransitionMatrix() TransitionMatrix

func (HmmTransitionMatrix) GetMatrix

func (obj HmmTransitionMatrix) GetMatrix() Matrix

func (HmmTransitionMatrix) Normalize

func (obj HmmTransitionMatrix) Normalize() error

type Mixture

type Mixture struct {
	LogWeights Vector
	// contains filtered or unexported fields
}

func NewMixture

func NewMixture(weights Vector) (*Mixture, error)

func (*Mixture) Clone

func (obj *Mixture) Clone() *Mixture

func (*Mixture) EmStep

func (obj *Mixture) EmStep(mixture1, mixture2 *Mixture, data MixtureDataSet, meta ConstVector, tmp []EmTmp, p ThreadPool) (float64, error)

func (*Mixture) ExportConfig

func (obj *Mixture) ExportConfig() ConfigDistribution

func (*Mixture) GetParameters

func (obj *Mixture) GetParameters() Vector

func (*Mixture) ImportConfig

func (obj *Mixture) ImportConfig(config ConfigDistribution, t ScalarType) error

func (*Mixture) Likelihood

func (obj *Mixture) Likelihood(r Scalar, data MixtureDataRecord, states []int) error

func (*Mixture) LogPdf

func (obj *Mixture) LogPdf(r Scalar, data MixtureDataRecord) error

func (*Mixture) NComponents

func (obj *Mixture) NComponents() int

func (*Mixture) Posterior

func (obj *Mixture) Posterior(r Scalar, data MixtureDataRecord, states []int) error

func (*Mixture) ScalarType

func (obj *Mixture) ScalarType() ScalarType

func (*Mixture) SetParameters

func (obj *Mixture) SetParameters(parameters Vector) error

func (*Mixture) String

func (obj *Mixture) String() string

type MixtureDataRecord

type MixtureDataRecord interface {
	// evaluate component c
	LogPdf(r Scalar, c int) error
}

type MixtureDataSet

type MixtureDataSet interface {
	// evaluate component c on observation i
	LogPdf(r Scalar, c, i int) error
	// total number of observations
	GetCounts() []int
	// total number of observations
	GetN() int
}

type ProbabilityVector

type ProbabilityVector interface {
	Vector
	GetVector() Vector
	Normalize() error
	CloneProbabilityVector() ProbabilityVector
}

type TransitionMatrix

type TransitionMatrix interface {
	Matrix
	GetMatrix() Matrix
	Normalize() error
	CloneTransitionMatrix() TransitionMatrix
}

Jump to

Keyboard shortcuts

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