gaussian

package
v0.0.0-...-0953495 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2015 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	Type      string    `json:"type"`
	ModelName string    `json:"name,omitempty"`
	ModelDim  int       `json:"dim"`
	NSamples  float64   `json:"nsamples"`
	Diag      bool      `json:"diag"`
	Sumx      []float64 `json:"sumx,omitempty"`
	Sumxsq    []float64 `json:"sumx_sq,omitempty"`
	Mean      []float64 `json:"mean"`
	StdDev    []float64 `json:"sd"`
	// contains filtered or unexported fields
}

Model is a multivariate Gaussian distribution.

func NewModel

func NewModel(dim int, options ...Option) *Model

NewModel creates a new Gaussian model.

func Read

func Read(r io.Reader) (*Model, error)

Read unmarshals json data from an io.Reader into a model struct.

func ReadFile

func ReadFile(fn string) (*Model, error)

ReadFile unmarshals json data from a file into a model struct.

func (*Model) Clear

func (g *Model) Clear()

Clear resets sufficient statistics.

func (*Model) Dim

func (g *Model) Dim() int

Dim is the dimensionality of the observation vector.

func (*Model) Estimate

func (g *Model) Estimate() error

Estimate computes model parameters using sufficient statistics.

func (*Model) LogProb

func (g *Model) LogProb(obs model.Obs) float64

LogProb returns log probability for observation.

func (*Model) Name

func (g *Model) Name() string

Name returns the name of the model.

func (*Model) Predict

func (g *Model) Predict(x model.Observer) ([]model.Labeler, error)

Predict returns a hypothesis given the observation.

func (*Model) Sample

func (g *Model) Sample(r *rand.Rand) model.Obs

Sample returns a Gaussian sample.

func (*Model) SampleChan

func (g *Model) SampleChan(r *rand.Rand, size int) <-chan model.Obs

SampleChan returns a channel with "size" samples drawn from the model. The sequence ends when the channel closes.

func (*Model) String

func (g *Model) String() string

String returns a json string.

func (*Model) ToJSON

func (g *Model) ToJSON() (string, error)

ToJSON returns a json string.

func (*Model) Update

func (g *Model) Update(x model.Observer, w func(model.Obs) float64) error

Update updates sufficient statistics using observations.

func (*Model) UpdateOne

func (g *Model) UpdateOne(o model.Obs, w float64)

UpdateOne updates sufficient statistics using one observation.

func (*Model) Write

func (g *Model) Write(w io.Writer) error

Write writes the model to an io.Writer.

func (*Model) WriteFile

func (g *Model) WriteFile(fn string) error

WriteFile writes the model to file.

type Option

type Option func(*Model)

Option type is used to pass options to NewModel().

func Clone

func Clone(src *Model) Option

Clone create a clone of src.

func Mean

func Mean(mean []float64) Option

Mean is an option function. Use it to set a mean vector when creating a new Gaussian model.

func Name

func Name(name string) Option

Name is an option to set the model name.

func StdDev

func StdDev(sd []float64) Option

StdDev is an option function. Use it to set a standard deviation vector when creating a new Gaussian model.

Jump to

Keyboard shortcuts

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