DSPRelated.com
Forums

Quantization Error

Started by ArunPrakash September 28, 2015
I wonder,

How could the quantization (by truncation)  error, E,  for negative
fractional numbers represented using ones complement is bounded by 0 <= E
< 2^-b ? (i.e, the error is positive)

For ex, with (b+1) bits (b=3 for magnitude, and 1 bit for sign)

Using 1s complement the number, X = -(1/8) is represented in binary as X=
(1.110). If it is truncated to 1 bit , then X=(1.1), which is in decimal
equals -(3/8). Therefore the  error is given by

                 E = Q(X) - X;

                 E = -3/8 +1/8 = -(2/8)

which is in contradiction with the error bound for negative fractional
numbers using ones complement representation.

Reference: Digital Signal Processing by Oppenheim & Schafer

Thank you.


---------------------------------------
Posted through http://www.DSPRelated.com
On Mon, 28 Sep 2015 12:43:32 -0500, ArunPrakash wrote:

> I wonder, > > How could the quantization (by truncation) error, E, for negative > fractional numbers represented using ones complement is bounded by 0 <= > E < 2^-b ? (i.e, the error is positive) > > For ex, with (b+1) bits (b=3 for magnitude, and 1 bit for sign) > > Using 1s complement the number, X = -(1/8) is represented in binary as > X= > (1.110). If it is truncated to 1 bit , then X=(1.1), which is in decimal > equals -(3/8). Therefore the error is given by > > E = Q(X) - X; > > E = -3/8 +1/8 = -(2/8) > > which is in contradiction with the error bound for negative fractional > numbers using ones complement representation. > > Reference: Digital Signal Processing by Oppenheim & Schafer
So, are you saying that O&S says that quantization by truncation in negative ones-compliment numbers is positive, while your own experience says it's negative? If X=(1.1) is a two-bit ones-compliment number, then in decimal X = -0 (because X=(0.0) is +0, and thus X=(1.1) is -0). So I'm not so sure about your analysis. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
On 9/28/15 6:13 PM, Tim Wescott wrote:
> On Mon, 28 Sep 2015 12:43:32 -0500, ArunPrakash wrote: > >> I wonder, >> >> How could the quantization (by truncation) error, E, for negative >> fractional numbers represented using ones complement is bounded by 0<= >> E< 2^-b ? (i.e, the error is positive) >> >> For ex, with (b+1) bits (b=3 for magnitude, and 1 bit for sign) >> >> Using 1s complement the number, X = -(1/8) is represented in binary as >> X= >> (1.110). If it is truncated to 1 bit , then X=(1.1), which is in decimal >> equals -(3/8). Therefore the error is given by >> >> E = Q(X) - X; >> >> E = -3/8 +1/8 = -(2/8) >> >> which is in contradiction with the error bound for negative fractional >> numbers using ones complement representation. >> >> Reference: Digital Signal Processing by Oppenheim& Schafer > > So, are you saying that O&S says that quantization by truncation in > negative ones-compliment numbers is positive, while your own experience > says it's negative? > > If X=(1.1) is a two-bit ones-compliment number, then in decimal X = -0 > (because X=(0.0) is +0, and thus X=(1.1) is -0). So I'm not so sure > about your analysis. >
he was saying "1s complement" (which is the same as "sign-magnitude"), in which if the truncation is done by masking off the bits, it will always "round toward zero". but i dunno anybody other than IEEE-754 that is doing sign-magnitude. normally, for quantization, it works consistently for positive or negative values. masking off bits of 2s-complement numbers will always round down. then the quantization error is always non-negative and less than the quantized LSB. if the OP is working with (IEEE) floating-point numbers and is quantizing, he/she probably needs to use the floor() function or an equivalent. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
On Mon, 28 Sep 2015 19:19:50 -0400, robert bristow-johnson wrote:

> On 9/28/15 6:13 PM, Tim Wescott wrote: >> On Mon, 28 Sep 2015 12:43:32 -0500, ArunPrakash wrote: >> >>> I wonder, >>> >>> How could the quantization (by truncation) error, E, for negative >>> fractional numbers represented using ones complement is bounded by 0<= >>> E< 2^-b ? (i.e, the error is positive) >>> >>> For ex, with (b+1) bits (b=3 for magnitude, and 1 bit for sign) >>> >>> Using 1s complement the number, X = -(1/8) is represented in binary as >>> X= >>> (1.110). If it is truncated to 1 bit , then X=(1.1), which is in >>> decimal equals -(3/8). Therefore the error is given by >>> >>> E = Q(X) - X; >>> >>> E = -3/8 +1/8 = -(2/8) >>> >>> which is in contradiction with the error bound for negative fractional >>> numbers using ones complement representation. >>> >>> Reference: Digital Signal Processing by Oppenheim& Schafer >> >> So, are you saying that O&S says that quantization by truncation in >> negative ones-compliment numbers is positive, while your own experience >> says it's negative? >> >> If X=(1.1) is a two-bit ones-compliment number, then in decimal X = -0 >> (because X=(0.0) is +0, and thus X=(1.1) is -0). So I'm not so sure >> about your analysis. >> >> > he was saying "1s complement" (which is the same as "sign-magnitude"), > in which if the truncation is done by masking off the bits, it will > always "round toward zero". but i dunno anybody other than IEEE-754 > that is doing sign-magnitude. > > normally, for quantization, it works consistently for positive or > negative values. masking off bits of 2s-complement numbers will always > round down. then the quantization error is always non-negative and less > than the quantized LSB. > > if the OP is working with (IEEE) floating-point numbers and is > quantizing, he/she probably needs to use the floor() function or an > equivalent.
One's compliment and sign-magnitude are not the same: <https:// en.wikipedia.org/wiki/ Signed_number_representations#Signed_magnitude_representation>. One's compliment denotes negative numbers by changing the sense of _all_ the bits. Sign-magnitude just sets the sign bit. So 1000b in 4-bit one's compliment is -7, while 1000b in 4-bit sign-magnitude is -0. In the complimentary case, 1111b in 4-bit one's compliment is -0, while 1111b in 4-bit sign-magnitude is -7. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Tim Wescott <seemywebsite@myfooter.really> wrote:
> On Mon, 28 Sep 2015 19:19:50 -0400, robert bristow-johnson wrote:
(snip)
>> he was saying "1s complement" (which is the same as "sign-magnitude"), >> in which if the truncation is done by masking off the bits, it will >> always "round toward zero". but i dunno anybody other than IEEE-754 >> that is doing sign-magnitude.
(snip)
> One's compliment and sign-magnitude are not the same: <https:// > en.wikipedia.org/wiki/ > Signed_number_representations#Signed_magnitude_representation>.
Ones complement is what you get exclusive oring all the non-sign bits with the sign bit. In the sense Robert was using it, the result is the same. If someone inverted all the bits of a bit representation, would you consider it the same enough?
> One's compliment denotes negative numbers by changing the sense of _all_ > the bits. Sign-magnitude just sets the sign bit. So 1000b in 4-bit > one's compliment is -7, while 1000b in 4-bit sign-magnitude is -0. In > the complimentary case, 1111b in 4-bit one's compliment is -0, while > 1111b in 4-bit sign-magnitude is -7.
-- glen
On 9/29/2015 2:55 AM, glen herrmannsfeldt wrote:
> Tim Wescott <seemywebsite@myfooter.really> wrote: >> On Mon, 28 Sep 2015 19:19:50 -0400, robert bristow-johnson wrote: > > (snip) > >>> he was saying "1s complement" (which is the same as "sign-magnitude"), >>> in which if the truncation is done by masking off the bits, it will >>> always "round toward zero". but i dunno anybody other than IEEE-754 >>> that is doing sign-magnitude. > > (snip) > >> One's compliment and sign-magnitude are not the same: <https:// >> en.wikipedia.org/wiki/ >> Signed_number_representations#Signed_magnitude_representation>. > > Ones complement is what you get exclusive oring all the non-sign > bits with the sign bit. In the sense Robert was using it, the > result is the same. > > If someone inverted all the bits of a bit representation, would > you consider it the same enough?
I literally don't understand the way you are using words. What does "same enough" mean? -- Rick
>I wonder, > >How could the quantization (by truncation) error, E, for negative >fractional numbers represented using ones complement is bounded by 0 <=
E
>< 2^-b ? (i.e, the error is positive) > >For ex, with (b+1) bits (b=3 for magnitude, and 1 bit for sign) > >Using 1s complement the number, X = -(1/8) is represented in binary as
X(1.110). If it is truncated to 1 bit , then X=(1.1), which is in decimal
>equals -(3/8). Therefore the error is given by > > E = Q(X) - X; > > E = -3/8 +1/8 = -(2/8) > >which is in contradiction with the error bound for negative fractional >numbers using ones complement representation. > >Reference: Digital Signal Processing by Oppenheim & Schafer > >Thank you. > > >--------------------------------------- >Posted through http://www.DSPRelated.c
Ya, i got it. Thanks tom, Actually i made an assumption that, the negative number x=(1.100) is same as x=(1.1) without even verifying it. Because such an assumption is true for positive numbers. For ex, x=(0.100) is same as x=(0.1) which is 1/2 in decimal. --------------------------------------- Posted through http://www.DSPRelated.com
Thanks tim and Thank u all for ur response..
---------------------------------------
Posted through http://www.DSPRelated.com
rickman <gnuarm@gmail.com> wrote:

(snip, someone wrote)
>>> One's compliment and sign-magnitude are not the same: <https:// >>> en.wikipedia.org/wiki/ >>> Signed_number_representations#Signed_magnitude_representation>.
>> Ones complement is what you get exclusive oring all the non-sign >> bits with the sign bit. In the sense Robert was using it, the >> result is the same.
>> If someone inverted all the bits of a bit representation, would >> you consider it the same enough?
> I literally don't understand the way you are using words. What does > "same enough" mean?
The discussion relates to what happens when you shift bits. Some bits are zero and some one, but the effect doesn't depend on what you label the bits. You could label the bits A and B, or H and L, the logic is the same. If you relabel all the bits with different labels, the value is the same. For similar reasons, an arithmetic right shift of ones complement (shift all bits and duplicate the sign) and arithmetic right shift of sign magnitude (keep the sign bit, shift the rest, zero fill) will give the same numerical result, both different from the numerical result of an arithmetic right shift of a twos complement value. The easiest way to build a sign magnitude adder is to exclusive OR the sign bit with all the data bits, to convert to ones complement, use a ones complement adder, then convert (exclusive OR) back. -- glen
On 9/29/2015 6:22 AM, glen herrmannsfeldt wrote:
> rickman <gnuarm@gmail.com> wrote: > > (snip, someone wrote) >>>> One's compliment and sign-magnitude are not the same: <https:// >>>> en.wikipedia.org/wiki/ >>>> Signed_number_representations#Signed_magnitude_representation>. > >>> Ones complement is what you get exclusive oring all the non-sign >>> bits with the sign bit. In the sense Robert was using it, the >>> result is the same. > >>> If someone inverted all the bits of a bit representation, would >>> you consider it the same enough? > >> I literally don't understand the way you are using words. What does >> "same enough" mean? > > The discussion relates to what happens when you shift bits. > > Some bits are zero and some one, but the effect doesn't depend > on what you label the bits. You could label the bits A and B, > or H and L, the logic is the same. If you relabel all the bits > with different labels, the value is the same. > > For similar reasons, an arithmetic right shift of ones complement > (shift all bits and duplicate the sign) and arithmetic right shift of > sign magnitude (keep the sign bit, shift the rest, zero fill) > will give the same numerical result, both different from the numerical > result of an arithmetic right shift of a twos complement value. > > The easiest way to build a sign magnitude adder is to exclusive OR > the sign bit with all the data bits, to convert to ones complement, > use a ones complement adder, then convert (exclusive OR) back.
Now I'm really lost. Nowhere until now has anyone mentioned shifting bits. The discussion was about Quantization Error of 1's complement numbers. I didn't understand what you were trying to say about one's complement and now you take a left turn into shifting data. -- Rick