傾きとバイアスの計算
傾きバイアス スケーリングとは
傾きバイアス スケーリングでは、数値の傾きとバイアスを指定しなければなりません。傾きバイアスのスケーリングされた数値の実際値は以下で表すことができます。
傾きとバイアスの計算
目的のエンドポイント、符号属性、および語長で開始します。
lower_bound = 999; upper_bound = 1000; is_signed = true; word_length = 16;
指定された語長および符号属性の fi オブジェクトの範囲を見つけるには、関数 range を使用します。
[Q_min, Q_max] = range(fi([], is_signed, word_length, 0));
傾きとバイアスを求めるには、次の連立方程式を解きます。
lower_bound = slope * Q_min + bias
upper_bound = slope * Q_max + bias
これらの方程式を行列の形式で書き換えます。
傾きとバイアスの解を求めます。
A = double ([Q_min, 1; Q_max, 1]); b = double ([lower_bound; upper_bound]); x = A\b; format long g
傾き、つまり精度を求めるには、傾きバイアス ベクトル x の最初の要素を呼び出します。
slope = x(1)
slope =
1.52590218966964e-05バイアスを求めるには、ベクトル x の 2 番目の要素を呼び出します。
bias = x(2)
bias =
999.500007629511傾きバイアス スケーリングを指定して numerictype オブジェクトを作成します。
T = numerictype(is_signed, word_length, slope, bias)
T =
DataTypeMode: Fixed-point: slope and bias scaling
Signedness: Signed
WordLength: 16
Slope: 1.5259021896696368e-5
Bias: 999.500007629511numerictype T を指定して fi オブジェクトを作成します。
a = fi(999.255, T)
a =
999.254993514916
DataTypeMode: Fixed-point: slope and bias scaling
Signedness: Signed
WordLength: 16
Slope: 1.5259021896696368e-5
Bias: 999.500007629511a の範囲を見つけて、作成した fi オブジェクトが正しく指定されていることを確認します。
range(a)
ans =
999 1000
DataTypeMode: Fixed-point: slope and bias scaling
Signedness: Signed
WordLength: 16
Slope: 1.5259021896696368e-5
Bias: 999.500007629511