Documentation

## Net Slope and Net Bias Precision

### What are Net Slope and Net Bias?

You can represent a fixed-point number by a general slope and bias encoding scheme

`$V\approx \stackrel{˜}{V}=SQ+B,$`

where:

• $V$ is an arbitrarily precise real-world value.

• $\stackrel{˜}{V}$ is the approximate real-world value.

• Q, the stored value, is an integer that encodes V.

• S = F2E is the slope.

• B is the bias.

For a cast operation,

`${S}_{a}{Q}_{a}+{B}_{a}={S}_{b}{Q}_{b}+{B}_{b}$`

or

`${Q}_{a}=\frac{{S}_{b}{Q}_{b}}{{S}_{a}}+\left(\frac{{B}_{b}-{B}_{a}}{{S}_{a}}\right),$`

where:

• $\frac{{S}_{b}}{{S}_{a}}$ is the net slope.

• $\frac{{B}_{b}-{B}_{a}}{{S}_{a}}$ is the net bias.

### Detecting Net Slope and Net Bias Precision Issues

Precision issues might occur in the fixed-point constants, net slope and net bias, due to quantization errors when you convert from floating point to fixed point. These fixed-point constant precision issues can result in numerical inaccuracy in your model.

You can configure your model to alert you when fixed-point constant precision issues occur. For more information, see Detect Net Slope and Bias Precision Issues. The Fixed-Point Designer™ software provides the following information:

• The type of precision issue: underflow, overflow, or precision loss.

• The original value of the fixed-point constant.

• The quantized value of the fixed-point constant.

• The error in the value of the fixed-point constant.

• The block that introduced the error.

This information warns you that the outputs from this block are not accurate. If possible, change the data types in your model to fix the issue.

### Fixed-Point Constant Underflow

Fixed-point constant underflow occurs when the Fixed-Point Designer software encounters a fixed-point constant whose data type does not have enough precision to represent the ideal value of the constant, because the ideal value is too close to zero. Casting the ideal value to the fixed-point data type causes the value of the fixed-point constant to become zero. Therefore the value of the fixed-point constant differs from its ideal value.

### Fixed-Point Constant Overflow

Fixed-point constant overflow occurs when the Fixed-Point Designer software converts a fixed-point constant to a data type whose range is not large enough to accommodate the ideal value of the constant with reasonable precision. The data type cannot accurately represent the ideal value because the ideal value is either too large or too small. Casting the ideal value to the fixed-point data type causes overflow. For example, suppose the ideal value is `200` and the converted data type is `int8`. Overflow occurs in this case because the maximum value that `int8` can represent is `127`.

The Fixed-Point Designer software reports an overflow error if the quantized value differs from the ideal value by more than the precision for the data type. The precision for a data type is approximately equal to the default scaling (for more information, see Fixed-Point Data Type Parameters.) Therefore, for positive values, the Fixed-Point Designer software treats errors greater than the slope as overflows. For negative values, it treats errors greater than or equal to the slope as overflows.

For example, the maximum value that `int8` can represent is `127`. The precision for `int8` is `1.0`. An ideal value of `127.3` quantizes to `127` with an absolute error of `0.3`. Although the ideal value `127.3` is greater than the maximum representable value for `int8`, the quantization error is small relative to the precision of `int8`. Therefore the Fixed-Point Designer software does not report an overflow. However, an ideal value of `128.1` does cause an overflow because the quantization error is `1.1`, which is larger than the precision for `int8`.

### Note

Fixed-point constant overflow differs from fixed-point constant precision loss. Precision loss occurs when the ideal fixed-point constant value is within the range of the current data type and scaling, but the software cannot represent this value exactly.

### Fixed-Point Constant Precision Loss

Fixed-point constant precision loss occurs when the Fixed-Point Designer software converts a fixed-point constant to a data type without enough precision to represent the exact value of the constant. As a result, the quantized value differs from the ideal value. For an example of this behavior, see Detect Fixed-Point Constant Precision Loss.

### Note

Fixed-point constant precision loss differs from fixed-point constant overflow. Overflow occurs when the range of the parameter data type, that is, the maximum value that it can represent, is smaller than the ideal value of the parameter.

Get trial now