Fit curve to nonsmooth empirical BER data
fits a curve to the empirical BER data,
fitber = berfit(
empber, and returns a vector of
fitted BER points. The values in
correspond to the empirical energy per bit to noise power spectral density ratio
values given by
empEbNo. For a general description of unconstrained
nonlinear optimization, see .
berfit function is intended for curve fitting or
interpolation (not extrapolation). Extrapolating BER data beyond an order of magnitude
below the smallest empirical BER value is inherently unreliable.
berfit(___) plots the empirical
and fitted BER data.
plots the empirical and fitted BER data from all possible settings of
fittype that are valid. If you do not want to override the default
options for optimization, specify
options as [ ].
To be valid a fit must conform to these criteria, otherwise it is rejected.
greater than or equal to 0 and less than or equal to 1
This example shows the use of the
berfit function using hard-coded or theoretical BER points for simplicity. For an example that uses empirical BER data from a simulation, see Use Curve Fitting on Error Rate Plot.
Best Fit for Set of Sample Data
Define a range of values and BER points. Use this data as inputs for the
EbN0 = 0:13; berdata = [.2 .15 .13 .12 .08 .09 .08 .07 .06 .04 .03 .02 .01 .004]; berfit(EbN0,berdata);
Plot Best Fit
The curve connects the points created by evaluating the fit expression at the specified values. To make the curve look smoother, provide an input vector of values for curve fitting in ascending order. This vector provides more points for plotting the curve and does not change the fit expression.
fitEbNo = 0:0.2:13; berfit(EbN0,berdata,fitEbNo)
Fit for BER Curve with Error Floor
berfit function using the
'all' option on empirical BER results for a simulation of BPSK data transmitted over a channel with a null (
ch = [0.5 0.47]) and recovered by using a linear MMSE equalizer at the receiver for the range [-10, 15]. Comparing the results of curve fitting methods
'doubleExp+const' fit type does not provide a valid fit
'exp' fit type does not work well for this data
'polyRatio' fit types closely match the simulated data
EbN0 = -10:3:15; empBER = [0.3361 0.3076 0.2470 0.1878 0.1212 0.0845 0.0650 0.0540 0.0474]; figure; berfit(EbN0,empBER,,,'all');
options Input Structure and
fitprops Output Structure
'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 indicates which fit type converges.
Generate theoretical BER results for 8-PSK data with a diversity order of 2 transmitted over a Rayleigh fading channel for the range [3, 10] dB.
M = 8; EbN0 = 3:10; berdata = berfading(EbN0,'psk',M,2); % Compute the theoretical BER noisydata = berdata.*[.93 .92 1 .59 .08 .15 .01 .01];
options structure by using the
optimset function to configure display and notification of fit type results. Run exponential and polynomial ratio fit types.
options = optimset('display','notify'); disp('*** Trying exponential fit.') % Poor fit
*** Trying exponential fit.
[fitber1,fitprops1] = berfit(EbN0,noisydata,EbN0,... options,'exp')
Exiting: Maximum number of function evaluations has been exceeded - increase MaxFunEvals option. Current function value: 2.749919
fitber1 = 1×8 0.1247 0.0727 0.0376 0.0168 0.0064 0.0020 0.0005 0.0001
fitprops1 = struct with fields: fitType: 'exp' coeffs: [4x1 double] sumSqErr: 2.7499 exitState: 'The maximum number of function evaluations has been exceeded' funcCount: 10001 iterations: 6193
disp('*** Trying polynomial ratio fit.') % Good fit
*** Trying polynomial ratio fit.
[fitber2,fitprops2] = berfit(EbN0,noisydata,EbN0,... options,'polyRatio')
fitber2 = 1×8 0.1701 0.0874 0.0407 0.0169 0.0060 0.0016 0.0003 0.0001
fitprops2 = struct with fields: fitType: 'polyRatio' coeffs: [6x1 double] sumSqErr: 2.3880 exitState: 'The curve fit converged to a solution' funcCount: 554 iterations: 331
empEbNo— Empirical Eb/N0 values
Empirical Eb/N0 values in dB, specified as a vector with at least four elements. The element values in the vector must be in ascending order.
empber— Empirical BER data
Empirical BER data, specified as a vector with the same number of elements as input
empEbNo. The values in
empber correspond to
values given by
fitEbNo— Eb/N0 values for curve fitting
values in dB for curve fitting, specified as a vector with element values in ascending
order. The length of
fitEbNo must equal or exceed that of input
options— Override default options used for optimization
Override default options used for optimization, specified as a structure. The fields
specified in the
options structure are used by the
fminsearch function. You can create the
structure by using the
optimset function. This table describes
the fields that are most relevant when using the
function. To use default options, you can specify this input as [ ].
Level of display.
|The maximum number of function evaluations before optimization ceases. The default is 104.|
|The maximum number of iterations before optimization ceases. The default is 104.|
|The termination tolerance for the closed-form function used to generate the fit. The default is 10-4.|
|The termination tolerance for the coefficient values of the closed-form function used to generate the fit. The default is 10-4.|
fittype— Closed-form function used to fit empirical data
Closed-form function used to fit the empirical data, specified as
'doubleExp+const'. For more
information, see Algorithms.
fitber— Fitted BER points
Fitted BER points, returned as a vector. The BER is computed for each
setting specified by the input
fitprops— Fit properties
Fit properties, returned as a structure with these fields to describe the properties of the curve fit.
|The closed-form function type used to generate the fit. Valid values
|The coefficients used to generate the fit. If the function cannot find a
valid fit, |
|The sum squared error between the log of the fitted BER points and the log of the empirical BER points.|
The exit condition of
|The number of function evaluations used in minimizing the sum squared error function.|
|The number of iterations taken in minimizing the sum squared error function. This value is not necessarily equal to the number of function evaluations.|
berfit function fits the BER data using unconstrained nonlinear
optimization via the
fminsearch function. This table lists the
closed-form functions that
berfit considers based on the value of the
fittype input argument. 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. In the functional expressions,
x is a linear
value (not a dB value), and f(x) is the estimated BER.
The sum squared error function that
fminsearch attempts to minimize is
The fitted BER points are the values in the output
fitber, and the sum is over the
points given in the input
empEbNo. To avoid high-BER regions dominating
the objective function, the sum squared equation uses the log of the BER values rather than
the BER values themselves.
 Chapra, Steven C., and Raymond P. Canale. Numerical Methods for Engineers. Fourth Edition. New York, McGraw-Hill, 2002.