Sample: Generate random samples from a channel distribution.

Description Usage Arguments Value Author(s) See Also Examples

Description

For a given information channel and input, draw random samples of the conditional probability distribution over the channel output.

Usage

1
Sample(channel, n, index, show.progress = FALSE)

Arguments

channel

An information channel, as returned by BlahutAlgorithm, FindOptimalChannel, or FindRate.

n

The number of random samples to generate.

index

The channel input, specified as its index in the source alphabet.

show.progress

Logical value. Show a progress bar during sampling?

Value

A list with two elements:

x

A matrix with n rows containing the channel input.

y

A matrix containing random samples of the channel output for the given index.

Author(s)

Chris R. Sims

See Also

BlahutAlgorithm, FindOptimalChannel, FindRate

Examples

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

# Draw random samples from the output of this channel, for a given input
samples <- Sample(channel, 1000, 50, show.progress = TRUE)

# Plot a histogram of the output
hist(samples$y)

RateDistortion documentation built on May 1, 2019, 9:52 p.m.