# 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

1 | ```
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. |

### Author(s)

Chris R. Sims

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ```
# 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)
``` |

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.