Main Content

dpcmopt

Optimize differential pulse code modulation parameters

Syntax

predictor = dpcmopt(training_set,ord)
[predictor,codebook,partition] = dpcmopt(training_set,ord,len)
[predictor,codebook,partition] = dpcmopt(training_set,ord,ini_cb)

Description

predictor = dpcmopt(training_set,ord) returns a vector representing a predictive transfer function of order ord that is appropriate for the training data in the vector training_set. predictor is a row vector of length ord+1. See Represent Predictors for more about its format.

Note

dpcmopt optimizes for the data in training_set. For best results, training_set should be similar to the data that you plan to quantize.

[predictor,codebook,partition] = dpcmopt(training_set,ord,len) is the same as the syntax above, except that it also returns corresponding optimized codebook and partition vectors codebook and partition. len is an integer that prescribes the length of codebook. partition is a vector of length len-1. For a description of the formats of partition and codebook, see Quantization.

[predictor,codebook,partition] = dpcmopt(training_set,ord,ini_cb) is the same as the first syntax, except that it also returns corresponding optimized codebook and partition vectors codebook and partition. ini_cb, a vector of length at least 2, is the initial guess of the codebook values. The output codebook is a vector of the same length as ini_cb. The output partition is a vector whose length is one less than the length of codebook.

Examples

collapse all

To optimize a DPCM-encoded and -decoded sawtooth signal, use the dpcmopt function with the dpcmenco and dpcmdeco functions. Testing and selecting parameters for large signal sets with a fine quantization scheme can be tedious. One way to produce partition, codebook, and predictor parameters easily is to optimize them according to a set of training data. The training data should be typical of the kinds of signals to be quantized with dpcmenco.

This example uses the predictive order, 1, as the desired order of the new optimized predictor. The dpcmopt function creates these optimized parameters, using the sawtooth signal x as training data. The example goes on to quantize the training data itself. In theory, the optimized parameters are suitable for quantizing other data that is similar to x. The mean square distortion for optimized DPCM is much less than the distortion with nonoptimized DPCM parameters.

Define variables for a sawtooth signal and initial DPCM parameters.

t = [0:pi/50:2*pi];
x = sawtooth(3*t);
partition = [-1:.1:.9];
codebook = [-1:.1:1];
predictor = [0 1];      % y(k)=x(k-1)

Optimize the partition, codebook, and predictor vectors by using the dpcmopt function and the initial codebook and order 1. Then generate DPCM encoded signals by using the initial and the optimized partition and codebook vectors.

[predictorOpt,codebookOpt,partitionOpt] = dpcmopt(x,1,codebook);
encodedx = dpcmenco(x,codebook,partition,predictor);
encodedxOpt = dpcmenco(x,codebookOpt,partitionOpt,predictorOpt);

Try to recover x from the modulated signal by using DPCM decoding. Compute the mean square error between the original signal and the decoded and optimized decoded signals.

decodedx = dpcmdeco(encodedx,codebook,predictor);
decodedxOpt = dpcmdeco(encodedxOpt,codebookOpt,predictorOpt);
distor = sum((x-decodedx).^2)/length(x);
distorOpt = sum((x-decodedxOpt).^2)/length(x);

Compare mean square distortions for quantization with the initial and optimized input arguments.

[distor, distorOpt]
ans = 1×2

    0.0327    0.0009

Version History

Introduced before R2006a