Learn R Programming

RateDistortion (version 1.01)

DifferenceDistribution: Compute the difference distribution for a given channel.

Description

This function computes the probability distribution over the quantity y - x, where x is the channel input and y is the channel output. Note that this function is only meaningful where the difference operator can meaningfully be applied to x and y. In addition, it is only implemented for univariate probability distributions; that is, channels where both the input and output alphabet are described by a vector.

Usage

DifferenceDistribution(channel)

Arguments

channel
An information channel, as computed by BlahutAlgorithm or FindOptimalChannel.

Value

A list with two elements:
diff
The vector of difference elements z = y - x
p
The probability distribution over the vector diff.

Examples

Run this code
# Define a discretized Gaussian information source
x <- seq(from = -10, to = 10, length.out = 100)
Px <- dnorm(x, mean = 0, sd = 3)
Px <- Px / sum(Px) # Ensure that probability sums to 1
y <- x # The destination alphabet is the same as the source

# Define a quadratic cost function
cost.function <- function(x, y) {
    (y - x)^2
}

# Slope of the rate-distortion curve
s <- -1

# Compute the rate-distortion value at the given point s
channel <- BlahutAlgorithm(x, Px, y, cost.function, s)

# Compute & plot the channel difference (or error) distribution
diff.distribution <- DifferenceDistribution(channel)
plot(diff.distribution$diff, diff.distribution$p)

Run the code above in your browser using DataLab