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 (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 ¶
func (ch BSC) Sample(input variable.RandomVariable) variable.RandomVariable
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 ¶
Do the input and output currently match?
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 ¶
Create a new binary symmetric channel with the specified noise rates.
func (BSCPair) Factor ¶
func (ch BSCPair) Factor(input variable.RandomVariable, output variable.RandomVariable) factor.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 ¶
func (ch BSCPair) Sample(input variable.RandomVariable) variable.RandomVariable
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