factor

package
v0.0.0-...-d568a9c Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstFactor

type ConstFactor struct {
	Vars  []variable.RandomVariable
	Value float64
}

A Factor which always returns the same value

func NewConstFactor

func NewConstFactor(vars []variable.RandomVariable, value float64) *ConstFactor

Create a new factor which always returns the same score

func (ConstFactor) Adjacent

func (factor ConstFactor) Adjacent() []variable.RandomVariable

The adjacent random variables

func (ConstFactor) Score

func (factor ConstFactor) Score() float64

The log probability of the variables given the parameters

type DistFactor

type DistFactor struct {
	Vars []variable.RandomVariable
	Dist dist.Dist
}

A factor which scores variables based on a probability distribution

func NewDistFactor

func NewDistFactor(vars []variable.RandomVariable, distr dist.Dist) *DistFactor

Create a new factor which scores based on a probability distribution. The variables are split into "variables" and "parameters" using the distribution's NumVars() and NumParams() values.

func (DistFactor) Adjacent

func (factor DistFactor) Adjacent() []variable.RandomVariable

The adjacent random variables

func (DistFactor) Score

func (factor DistFactor) Score() float64

The log probability of the variables given the parameters

type Factor

type Factor interface {

	// The adjacent random variables
	Adjacent() []variable.RandomVariable

	// The factor's current score, based on the values of adjacent variables
	Score() float64
}

A connecting node in a factor graph. A factor is a node with edges to random variable nodes, and which has a corresponding function to score the values of those random variables.

type FactorGraph

type FactorGraph struct {
	Factors   []Factor
	Variables []factorGraphVar
	// contains filtered or unexported fields
}

A FactorGraph is a bipartite graph between random variables and factors. The joint probability distribution over all random variables is the product of all factors, calculated over their adjacent random variables.

func NewFactorGraph

func NewFactorGraph() *FactorGraph

Create a new factor graph

func (*FactorGraph) AddFactor

func (graph *FactorGraph) AddFactor(factor Factor)

Add a factor and its adjacent random variables to the graph

func (*FactorGraph) AddFactors

func (graph *FactorGraph) AddFactors(factors []Factor)

Add multiple factors to the graph

func (FactorGraph) AdjToFactor

func (graph FactorGraph) AdjToFactor(factor Factor) []variable.RandomVariable

Get variables adjacent to a factor

func (FactorGraph) AdjToVariable

func (graph FactorGraph) AdjToVariable(v variable.RandomVariable) []Factor

Get factors adjacent to a variable

func (FactorGraph) Score

func (graph FactorGraph) Score() float64

Get the score (log probability) for the entire factor graph

func (FactorGraph) ScoreVar

func (graph FactorGraph) ScoreVar(v variable.RandomVariable) float64

Get the score (log probability measure) for a particular variable

Jump to

Keyboard shortcuts

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