Description Usage Arguments Value Author(s) Examples

View source: R/DifferenceDistribution.R

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.

1 | ```
DifferenceDistribution(channel)
``` |

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

A list with two elements:

`diff` |
The vector of difference elements z = y - x |

`p` |
The probability distribution over the vector diff. |

Chris R. Sims

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)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.