bsc

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: 6 Imported by: 0

Documentation

Overview

* Implements variations on a binary symmetric channel (BSC) with constant noise * rate p, which takes a "true" boolean value X as input and outputs X with * probability (1-p) and outputs !X with probability p. * * We send the many X values across many such channels, and attempt to infer * their respective noise rates and the values of the input variables based * on the rate of agreement between the channels.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BSC

type BSC struct {

	// The probability of flipping the input
	NoiseRate *variable.ContinuousRV

	channel.DefChannelSampleN
}

A binary symmetric channel. Given a Bernoulli random variable X, it emits a Bernoulli random variable Y such that with probability `NoiseRate` Y = !X, and Y = X otherwise. In other words, the channel has fixed probability `NoiseRate` of outputting Y with the opposite value of X.

func NewBSC

func NewBSC(noiseRate float64) *BSC

Create a new binary symmetric channel with the specified noise rate.

func (BSC) Factor

func (ch BSC) Factor(input variable.RandomVariable, output variable.RandomVariable) factor.Factor

Build a factor relating an input variable to an output variable

func (BSC) Factors

func (ch BSC) Factors(input variable.RandomVariable, outputs []variable.RandomVariable) []factor.Factor

Build factors relating an input variable to a sequence of output variables

func (BSC) Sample

Send an input to the channel and sample an output

type BSCFactor

type BSCFactor struct {
	Input, Output *variable.DiscreteRV
	NoiseRate     *variable.ContinuousRV
}

A factor connecting an input variable to its output, as perturbed by a constant Bernoulli noise rate.

func (BSCFactor) Adjacent

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

The adjacent random variables

func (BSCFactor) OutputMatchesInput

func (factor BSCFactor) OutputMatchesInput() bool

Do the input and output currently match?

func (BSCFactor) Score

func (factor BSCFactor) Score() float64

The factor's current score, based on the values of adjacent variables

type BSCPair

type BSCPair struct {

	// The probability of flipping the input for each layer of the channel
	NoiseRate1, NoiseRate2 *variable.ContinuousRV

	channel.DefChannelSampleN
}

A binary symmetric channel. Given a Bernoulli random variable X, it emits a Bernoulli random variable Y such that with probability `NoiseRate` Y = !X, and Y = X otherwise. In other words, the channel has fixed probability `NoiseRate` of outputting Y with the opposite value of X.

func NewBSCPair

func NewBSCPair(noiseRate1, noiseRate2 float64) *BSCPair

Create a new binary symmetric channel with the specified noise rates.

func (BSCPair) Factor

Build a factor relating an input variable to an output variable

func (BSCPair) Factors

func (ch BSCPair) Factors(input variable.RandomVariable, outputs []variable.RandomVariable) []factor.Factor

Build factors relating an input variable to a sequence of output variables

func (BSCPair) Sample

Send an input to the channel and sample an output

type BSCPairFactor

type BSCPairFactor struct {
	Input, Output          *variable.DiscreteRV
	NoiseRate1, NoiseRate2 *variable.ContinuousRV
}

A factor connecting an input variable to its output, as perturbed by a constant Bernoulli noise rate.

func (BSCPairFactor) Adjacent

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

The adjacent random variables

func (BSCPairFactor) OutputMatchesInput

func (factor BSCPairFactor) OutputMatchesInput() bool

Do the input and output currently match?

func (BSCPairFactor) Score

func (factor BSCPairFactor) Score() float64

The factor's current score, based on the values of adjacent variables

Jump to

Keyboard shortcuts

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