berfit

Fit curve to nonsmooth empirical BER data

Syntax

fitber = berfit(empEbNo,empber)
fitber = berfit(empEbNo,empber,fitEbNo)
fitber = berfit(empEbNo,empber,fitEbNo,options)
fitber = berfit(empEbNo,empber,fitEbNo,options,fittype)
[fitber,fitprops] = berfit(...)
berfit(...)
berfit(empEbNo,empber,fitEbNo,options,'all')

Description

fitber = berfit(empEbNo,empber) fits a curve to the empirical BER data in the vector empber and returns a vector of fitted bit error rate (BER) points. The values in empber and fitber correspond to the Eb/N0 values, in dB, given by empEbNo. The vector empEbNo must be in ascending order and must have at least four elements.

fitber = berfit(empEbNo,empber,fitEbNo) fits a curve to the empirical BER data in the vector empber corresponding to the Eb/N0 values, in dB, given by empEbNo. The function then evaluates the curve at the Eb/N0 values, in dB, given by fitEbNo and returns the fitted BER points. The length of fitEbNo must equal or exceed that of empEbNo.

fitber = berfit(empEbNo,empber,fitEbNo,options) uses the structure options to override the default options used for optimization. These options are the ones used by the fminsearch function. You can create the options structure using the optimset function. Particularly relevant fields are described in the table below.

FieldDescription
options.DisplayLevel of display: 'off' (default) displays no output; 'iter' displays output at each iteration; 'final' displays only the final output; 'notify' displays output only if the function does not converge.
options.MaxFunEvalsMaximum number of function evaluations before optimization ceases. The default is 104. Reducing this value might make the function faster but might reduce the quality of the fit.
options.MaxIterMaximum number of iterations before optimization ceases. The default is 104. Reducing this value might make the function faster but might reduce the quality of the fit.
options.TolFunTermination tolerance on the closed-form function used to generate the fit. The default is 10-4.
options.TolXTermination tolerance on the coefficient values of the closed-form function used to generate the fit. The default is 10-4.

fitber = berfit(empEbNo,empber,fitEbNo,options,fittype) specifies which closed-form function berfit uses to fit the empirical data, from the possible fits listed in Algorithm below. fittype can be 'exp', 'exp+const', 'polyRatio', or 'doubleExp+const'. To avoid overriding default optimization options, use options = [].

[fitber,fitprops] = berfit(...) returns the MATLAB structure fitprops, which describes the results of the curve fit. Its fields are described in the table below.

FieldDescription
fitprops.fitTypeThe closed-form function type used to generate the fit: 'exp', 'exp+const', 'polyRatio', 'doubleExp+const', or 'all'.
fitprops.coeffsThe coefficients used to generate the fit.
fitprops.sumSqErrThe sum squared error between the log of the fitted BER points and the log of the empirical BER points.
fitprops.exitStateThe exit condition of berfit: 'The curve fit converged to a solution.' or 'The maximum number of function evaluations was exceeded.'.
fitprops.funcCountThe number of function evaluations used in minimizing the sum squared error function.
fitprops.iterationsThe number of iterations taken in minimizing the sum squared error function. This is not necessarily equal to the number of function evaluations.

berfit(...) plots the empirical and fitted BER data.

berfit(empEbNo,empber,fitEbNo,options,'all') plots the empirical and fitted BER data from all the possible fits listed in Algorithm below. To avoid overriding default options, use options = [].

Examples

The examples below illustrate the syntax of the function, but use hard-coded or theoretical BER data for simplicity. For an example that uses empirical BER data from a simulation, see Example: Curve Fitting for an Error Rate Plot.

The code below plots the best fit for a sample set of data.

EbNo = [0:13];
berdata = [.2 .15 .13 .12 .08 .09 .08 .07 .06 .04 .03 .02 .01 .004];
berfit(EbNo,berdata); % Plot the best fit.

The curve connects the points created by evaluating the fit expression at the values in EbNo. To make the curve look smoother, use a syntax like berfit(EbNo,berdata,[0:0.2:13]). This alternative syntax uses more points when plotting the curve, but does not change the fit expression.

The next example plots all fit types that berfit considers, for a perturbation of a set of BER data obtained using the berfading function. Notice that one of the fit types does not work well for this data, while the other fit types provide much better fits.

M = 4; EbNo = [3:10];
berdata = berfading(EbNo,'psk',M,2); % Compute theoretical BER.
noisydata = berdata.*[.93 .92 .5 .89 .058 .35 .8 .01]; % Perturbed data
figure; berfit(EbNo,noisydata,EbNo,[],'all'); % Plot all four fits.

The code below illustrates the use of the options input structure as well as the fitprops output structure. The 'notify' value for the display level causes the function to produce output when one of the attempted fits does not converge. The exitState field of the output structure also indicates which fit converges and which fit does not.

M = 4; EbNo = [3:10];
berdata = berfading(EbNo,'psk',M,2); % Compute theoretical BER.
noisydata = berdata.*[.93 .92 .5 .89 .058 .35 .8 .01];
% Say when fit fails to converge.
options = optimset('display','notify');

disp('*** Trying polynomial ratio fit.') % Poor fit in this case
[fitber1,fitprops1] = berfit(EbNo,noisydata,EbNo,...
   options,'polyRatio')

disp('*** Trying double exponential + constant fit.') % Good fit
[fitber2,fitprops2] = berfit(EbNo,noisydata,EbNo,...
   options,'doubleExp+const')

The output is below.

*** Trying polynomial ratio fit.
 
Exiting: Maximum number of function evaluations has been exceeded
         - increase MaxFunEvals option.
         Current function value: 6.136681 


fitber1 =

  Columns 1 through 6 

    0.0472    0.0289    0.0187    0.0121    0.0077    0.0044

  Columns 7 through 8 

    0.0019    0.0001


fitprops1 = 

       fitType: 'polyRatio'
        coeffs: [6x1 double]
      sumSqErr: 6.1367
     exitState: [1x56 char]
     funcCount: 10001
    iterations: 3333

*** Trying double exponential + constant fit.

fitber2 =

  Columns 1 through 6 

    0.0338    0.0260    0.0192    0.0134    0.0087    0.0049

  Columns 7 through 8 

    0.0021    0.0001


fitprops2 = 

       fitType: 'doubleExp+const'
        coeffs: [9x1 double]
      sumSqErr: 6.7044
     exitState: 'The curve fit converged to a solution.'
     funcCount: 1237
    iterations: 822

Algorithm

The berfit function fits the BER data using unconstrained nonlinear optimization via the fminsearch function. The closed-form functions that berfit considers are listed in the table below, where x is the Eb/N0 in linear terms (not dB) and f is the estimated BER. These functions were empirically found to provide close fits in a wide variety of situations, including exponentially decaying BERs, linearly varying BERs, and BER curves with error rate floors.

Value of fittypeFunctional Expression
'exp'

'exp+const'

'polyRatio'

'doubleExp+const'

The sum squared error function that fminsearch attempts to minimize is

where the fitted BER points are the values in empber and where the sum is over the Eb/N0 points given in empEbNo. It is important to use the log of the BER values rather than the BER values themselves so that the high-BER regions do not dominate the objective function inappropriately.

See Also

fminsearch, optimset, Performance Evaluation

References

For a general description of unconstrained nonlinear optimization, see the following work.

[1] Chapra, Steven C., and Raymond P. Canale, Numerical Methods for Engineers, Fourth Edition, New York, McGraw-Hill, 2002.


© 1994-2005 The MathWorks, Inc.